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

Conversation

davep
Copy link
Contributor

@davep davep commented Jun 1, 2023

See #2698.

davep added 2 commits June 1, 2023 10:37
The previous change actually broke some of the tests in test_disabled.py --
well actually it flat out broke one and caused all the others to run *very*
slowly. No clue why though.

But thinking about this some more, it does feel like delaying the refresh of
the node makes more sense.
@davep davep added enhancement New feature or request Task labels Jun 1, 2023
@davep davep self-assigned this Jun 1, 2023
@davep davep marked this pull request as ready for review June 1, 2023 10:42
@davep davep linked an issue Jun 1, 2023 that may be closed by this pull request
@@ -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.

@@ -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.

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!

@davep davep merged commit d0edd99 into Textualize:main Jun 1, 2023
@davep davep deleted the tree-node-label-change-should-refresh-the-tree branch June 1, 2023 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Updating a TreeNode.label doesn't refresh the tree right away
2 participants