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

Fix off-by-2 calculation in horizontal scrolling of Tree & DirectoryTree #4744

Merged
merged 3 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Fixed issue with `Tabs` where disabled tabs could still be activated by clicking the underline https://github.com/Textualize/textual/issues/4701
- Fixed scroll_visible with margin https://github.com/Textualize/textual/pull/4719
- Fixed programmatically disabling button stuck in hover state https://github.com/Textualize/textual/pull/4724
- Fixed `Tree` and `DirectoryTree` horizontal scrolling off-by-2 https://github.com/Textualize/textual/pull/4744

### Changed

Expand Down
8 changes: 4 additions & 4 deletions src/textual/widgets/_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ def _get_guide_width(self, guide_depth: int, show_root: bool) -> int:
Width in cells.
"""
if show_root:
return 2 + (max(0, len(self.path) - 1)) * guide_depth
width = (max(0, len(self.path) - 1)) * guide_depth
else:
guides = 2
width = 0
if len(self.path) > 1:
guides += (len(self.path) - 1) * guide_depth
width += (len(self.path) - 1) * guide_depth

return guides
return width


class TreeNodes(ImmutableSequenceView["TreeNode[TreeDataType]"]):
Expand Down
Loading
Loading