feat(interactive): ls: remember parent position (#1126)

This commit is contained in:
aawsome 2024-04-19 17:12:48 +02:00 committed by GitHub
parent 9980a36b7d
commit d8d4a93161
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -46,7 +46,7 @@ pub(crate) struct Snapshot<'a, P, S> {
repo: &'a Repository<P, S>,
snapshot: SnapshotFile,
path: PathBuf,
trees: Vec<Tree>,
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 {