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

Directory tree reload now preserves state #4123

Merged
merged 4 commits into from
Feb 7, 2024
Merged

Conversation

rodrigogiraoserrao
Copy link
Contributor

@rodrigogiraoserrao rodrigogiraoserrao commented Feb 5, 2024

Fixes #4056.

Adds an asyncio.Lock to Tree.
Adds a private coroutine DirectoryTree._reload used by DirectoryTree.reload/.reload_node that reloads a subtree and preserves expanded nodes + highlighted node.

Fixes #4122.
While working on the above I noticed this bug and I fixed it en passant.

@rodrigogiraoserrao rodrigogiraoserrao marked this pull request as ready for review February 5, 2024 17:30
Copy link
Collaborator

@willmcgugan willmcgugan left a comment

Choose a reason for hiding this comment

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

Great work. Just one thing to consider.

src/textual/widgets/_directory_tree.py Outdated Show resolved Hide resolved
Address review feedback by handling the error of trying to load a directory that doesn't exist instead of checking if it exists.
Review comment: https://github.com/Textualize/textual/pull/4123\#discussion_r1479504901
@willmcgugan willmcgugan merged commit 8036270 into main Feb 7, 2024
1 check was pending
@willmcgugan willmcgugan deleted the directory-tree-reload branch February 7, 2024 12:06
@JoeZiminski
Copy link

@rodrigogiraoserrao @willmcgugan That's awesome, thanks for this!

@willmcgugan
Copy link
Collaborator

All credit to Rodrigo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DirectoryTree.clear_node doesn't actually clear the node Reload directory tree and keep state
3 participants