From d8d4a93161ea04a5b97e9c17b8deedec49b59e3b Mon Sep 17 00:00:00 2001 From: aawsome <37850842+aawsome@users.noreply.github.com> Date: Fri, 19 Apr 2024 17:12:48 +0200 Subject: [PATCH] feat(interactive): ls: remember parent position (#1126) --- src/commands/tui/ls.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/commands/tui/ls.rs b/src/commands/tui/ls.rs index b1e37d7..6f000ed 100644 --- a/src/commands/tui/ls.rs +++ b/src/commands/tui/ls.rs @@ -46,7 +46,7 @@ pub(crate) struct Snapshot<'a, P, S> { repo: &'a Repository, snapshot: SnapshotFile, path: PathBuf, - trees: Vec, + trees: Vec<(Tree, usize)>, // Stack of parent trees with position tree: Tree, } @@ -147,7 +147,7 @@ impl<'a, P: ProgressBars, S: IndexedFull> Snapshot<'a, P, S> { self.path.push(node.name()); let tree = self.tree.clone(); self.tree = self.repo.get_tree(&node.subtree.unwrap())?; - self.trees.push(tree); + self.trees.push((tree, idx)); } } self.table.widget.set_to(0); @@ -157,9 +157,9 @@ impl<'a, P: ProgressBars, S: IndexedFull> Snapshot<'a, P, S> { pub fn goback(&mut self) -> bool { _ = self.path.pop(); - if let Some(tree) = self.trees.pop() { + if let Some((tree, idx)) = self.trees.pop() { self.tree = tree; - self.table.widget.set_to(0); + self.table.widget.set_to(idx); self.update_table(); false } else {