Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that a tree's node is refreshed right away when its label is changed #2713

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

### Fixed

- Fixed setting `TreeNode.label` on an existing `Tree` node not immediately https://github.com/Textualize/textual/pull/2713

## [0.27.0] - 2023-06-01

### Fixed
Expand Down
1 change: 1 addition & 0 deletions src/textual/widgets/_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ def set_label(self, label: TextType) -> None:
self._updates += 1
text_label = self._tree.process_label(label)
self._label = text_label
self._tree.call_later(self._tree._refresh_node, self)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I never know whether I should use call_later, call_soon, or the other one.
How do you decide?

Copy link
Contributor Author

@davep davep Jun 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean call_next rather than call_soon? I generally go with the rule that call_later is the one to go with unless it's obvious otherwise because jumping the queue should be an exceptional thing to do.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, thanks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't you refresh right here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling refresh directly broke much of test_disabled.py in a really fun way (try it and see, it's one of the weirdest breaks I've seen so far); some tests taking an age to complete, one just flat out breaking. I suspect some sort of deadly embrace going on; seemed to happen as the Tree in the tests was being spun up.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting!


def add(
self,
Expand Down