Skip to content

Commit

Permalink
Merge pull request #4210 from davep/fix-dirtree-path
Browse files Browse the repository at this point in the history
  • Loading branch information
davep authored Feb 26, 2024
2 parents 65c4cce + a9c5161 commit a2b72c5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Fixed `Sparkline` not working with data in a `deque` https://github.com/Textualize/textual/issues/3899
- Tooltips are now cleared when the related widget is no longer under them https://github.com/Textualize/textual/issues/3045
- Simplified tree-sitter highlight queries for HTML, which also seems to fix segfault issue https://github.com/Textualize/textual/pull/4195
- Fixed `DirectoryTree.path` no longer reacting to new values https://github.com/Textualize/textual/issues/4208

## [0.52.1] - 2024-02-20

Expand Down
1 change: 1 addition & 0 deletions src/textual/widgets/_directory_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ async def watch_path(self) -> None:
If the path is changed the directory tree will be repopulated using
the new value as the root.
"""
self.reset_node(self.root, str(self.path), DirEntry(self.PATH(self.path)))
await self.reload()

def process_label(self, label: TextType) -> Text:
Expand Down
20 changes: 20 additions & 0 deletions tests/directory_tree/test_change_path.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from pathlib import Path

from textual.app import App, ComposeResult
from textual.widgets import DirectoryTree


class DirectoryTreeApp(App[None]):

def compose(self) -> ComposeResult:
yield DirectoryTree(".")


async def test_change_directory_tree_path(tmpdir: Path) -> None:
"""The DirectoryTree should react to the path changing."""

async with DirectoryTreeApp().run_test() as pilot:
assert pilot.app.query_one(DirectoryTree).root.data.path == Path(".")
pilot.app.query_one(DirectoryTree).path = tmpdir
await pilot.pause()
assert pilot.app.query_one(DirectoryTree).root.data.path == tmpdir

0 comments on commit a2b72c5

Please sign in to comment.