From 67c1cbd482748a9d2295950c068505882c6b8bc4 Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Wed, 10 Jul 2024 09:19:56 +0100 Subject: [PATCH] Fix tree up/down parents not working when directory sits on very first/last line --- src/posting/widgets/tree.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/posting/widgets/tree.py b/src/posting/widgets/tree.py index f615e2c1..a88a1dd5 100644 --- a/src/posting/widgets/tree.py +++ b/src/posting/widgets/tree.py @@ -32,7 +32,7 @@ class PostingTree(Tree[T]): def action_cursor_up_parent(self) -> None: """Move the cursor to the previous collapsible node.""" start_line = max(self.cursor_line - 1, 0) - for line in range(start_line, 0, -1): + for line in range(start_line, -1, -1): node = self.get_node_at_line(line) if node and node.allow_expand: self.cursor_line = line @@ -42,7 +42,7 @@ def action_cursor_down_parent(self) -> None: """Move the cursor to the next collapsible node.""" max_index = len(self._tree_lines) - 1 start_line = min(self.cursor_line + 1, max_index) - for line in range(start_line, max_index): + for line in range(start_line, max_index + 1): node = self.get_node_at_line(line) if node and node.allow_expand: self.cursor_line = line