From e1111a24c6469ac967796f734f7348016da8014a Mon Sep 17 00:00:00 2001 From: Isaiah Odhner Date: Tue, 27 Jun 2023 12:58:06 -0400 Subject: [PATCH] Consolidate timers when scrolling to and selecting a node --- src/textual_paint/enhanced_directory_tree.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/textual_paint/enhanced_directory_tree.py b/src/textual_paint/enhanced_directory_tree.py index 726fa16..f16cb4d 100644 --- a/src/textual_paint/enhanced_directory_tree.py +++ b/src/textual_paint/enhanced_directory_tree.py @@ -12,12 +12,12 @@ class EnhancedDirectoryTree(DirectoryTree): def _go_to_node(self, node: TreeNode[DirEntry]) -> None: """Scroll to the node, and select it.""" - self.set_timer(0.01, lambda: self.select_node(node)) - def scroll_node_to_top(): + def _go_to_node_now(): + self.select_node(node) region = self._get_label_region(node._line) # type: ignore assert region, "Node not found in tree" self.scroll_to_region(region, animate=False, top=True) - self.set_timer(0.01, scroll_node_to_top) + self.set_timer(0.01, _go_to_node_now) def _expand_matching_child(self, node: TreeNode[DirEntry], remaining_parts: tuple[str]) -> None: """Hooks into DirectoryTree's add method, and expands the child node matching the next path part, recursively.