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

Reload directory tree and keep state #4056

Closed
willmcgugan opened this issue Jan 21, 2024 · 1 comment · Fixed by #4123
Closed

Reload directory tree and keep state #4056

willmcgugan opened this issue Jan 21, 2024 · 1 comment · Fixed by #4123
Assignees

Comments

@willmcgugan
Copy link
Collaborator

We need a way of reloading the directory tree on demand, so that it reflects any changes to the filesystem.

  • The reload should be atomic. i.e. it shouldn't permit modifications to the tree from another task. Otherwise it could get out-of-sync. Suggest we need a asyncio.Lock here.
  • The highlighted node should stay highlighted, assuming the node still exists. If the node has been removed, then the highlight should go up a directory.
  • Open directories should be reloaded recursively.
  • The loading directory information (including subdirectories) should happen in a thread, so as not block the main loop. Note that thins should probably be done in a single thread.

Suggested implementation:

  • In a thread (or threaded worker), recursively load the directories which have been expanded (assuming they exist).
  • Note the highlighted node, and the open nodes.
  • Update the DirectoryTree nodes to reflect the new data.
  • Restore the highlighted node.

Note than since we want this to be atomic, this should be done in a coroutine, or at least return an awaitable.

Supersedes #3574

Copy link

github-actions bot commented Feb 7, 2024

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

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 a pull request may close this issue.

2 participants