mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Merge pull request #2660 from davep/dirtree-tweaks
This commit is contained in:
@@ -131,8 +131,9 @@ class DirectoryTree(Tree[DirEntry]):
|
||||
node: The node to add to the load queue.
|
||||
"""
|
||||
assert node.data is not None
|
||||
node.data.loaded = True
|
||||
self._load_queue.put_nowait(node)
|
||||
if not node.data.loaded:
|
||||
node.data.loaded = True
|
||||
self._load_queue.put_nowait(node)
|
||||
|
||||
def reload(self) -> None:
|
||||
"""Reload the `DirectoryTree` contents."""
|
||||
@@ -271,6 +272,7 @@ class DirectoryTree(Tree[DirEntry]):
|
||||
node: The Tree node to populate.
|
||||
content: The collection of `Path` objects to populate the node with.
|
||||
"""
|
||||
node.remove_children()
|
||||
for path in content:
|
||||
node.add(
|
||||
path.name,
|
||||
@@ -350,8 +352,7 @@ class DirectoryTree(Tree[DirEntry]):
|
||||
if dir_entry is None:
|
||||
return
|
||||
if self._safe_is_dir(dir_entry.path):
|
||||
if not dir_entry.loaded:
|
||||
self._add_to_load_queue(event.node)
|
||||
self._add_to_load_queue(event.node)
|
||||
else:
|
||||
self.post_message(self.FileSelected(event.node, dir_entry.path))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user