diff options
Diffstat (limited to 'src/flat_tree.rs')
-rw-r--r-- | src/flat_tree.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/flat_tree.rs b/src/flat_tree.rs index d3a209c..8118821 100644 --- a/src/flat_tree.rs +++ b/src/flat_tree.rs @@ -163,12 +163,17 @@ impl PartialOrd for TreeLine { impl Tree { pub fn refresh(&mut self, page_height: usize) -> Result<(), errors::TreeBuildError> { - let builder = - TreeBuilder::from(self.root().to_path_buf(), self.options.clone(), page_height)?; + let builder = TreeBuilder::from( + self.root().to_path_buf(), + self.options.clone(), + page_height, + )?; let mut tree = builder.build(&TaskLifetime::unlimited()).unwrap(); // should not fail // we save the old selection to try restore it let selected_path = self.selected_line().path.to_path_buf(); mem::swap(&mut self.lines, &mut tree.lines); + self.selection = 0; // so that there's no error if we can't find the selection after refresh + self.scroll = 0; self.try_select_path(&selected_path); self.make_selection_visible(page_height as i32); Ok(()) |