diff --git a/helix-term/src/ui/explore.rs b/helix-term/src/ui/explore.rs index d2bb1b5b..96a064bf 100644 --- a/helix-term/src/ui/explore.rs +++ b/helix-term/src/ui/explore.rs @@ -863,7 +863,8 @@ impl Component for Explorer { } key!('[') => { if let Some(parent) = self.state.current_root.parent().clone() { - self.change_root(cx, parent.to_path_buf()) + let path = parent.to_path_buf(); + self.change_root(cx, path) } } key!(']') => self.change_root(cx, self.tree.current_item().path.clone()), diff --git a/helix-term/src/ui/tree.rs b/helix-term/src/ui/tree.rs index 23d6a95c..35929a82 100644 --- a/helix-term/src/ui/tree.rs +++ b/helix-term/src/ui/tree.rs @@ -270,32 +270,6 @@ impl Tree { self.children.iter().find_map(|elem| elem.get(index)) } } - fn traverse<'a, U, F>(&'a self, init: U, f: &F) -> U - where - F: Fn(U, usize, &'a Tree) -> U, - { - fn traverse<'a, T, U, F>( - tree: &'a Tree, - current_index: usize, - init: U, - f: &F, - ) -> (usize, U) - where - F: Fn(U, usize, &'a Tree) -> U, - { - let mut result = f(init, current_index, &tree); - let mut current_index = current_index; - for tree in &tree.children { - (current_index, result) = traverse(tree, current_index + 1, result, f) - } - (current_index, result) - // tree.children.iter().fold( - // (current_index, f(init, 0, &tree)), - // |(current_index, result), tree| traverse(tree, current_index + 1, result, &f), - // ) - } - traverse(self, 0, init, f).1 - } fn get_mut(&mut self, index: usize) -> Option<&mut Tree> { if self.index == index { @@ -488,7 +462,8 @@ impl TreeView { fn go_to_parent(&mut self) { if let Some(parent) = self.current_parent() { - self.set_selected(parent.index) + let index = parent.index; + self.set_selected(index) } }