diff options
author | Canop <cano.petrole@gmail.com> | 2019-11-27 21:01:12 +0100 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2019-11-27 21:07:15 +0100 |
commit | edf522ecaef2314b0f3a4e2ecf1c6a9a2790d9a1 (patch) | |
tree | 0087005b3edf56000876c44b339051f9e5c05f0a | |
parent | 110d29a4c726de3dd824a3b8e0aea5fdfa3bf161 (diff) |
fix crash on doing `:rm` on the last child of current rootv0.10.3
This was due to the selection index being kept when the previously
selected path isn't in the tree anymore.
-rw-r--r-- | CHANGELOG.md | 6 | ||||
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/flat_tree.rs | 9 |
4 files changed, 13 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index b22ec62..41b9d5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,9 @@ -### Master +<a name="v0.10.3"></a> +### v0.10.3 - 2019-11-27 +* fix crash on doing `:rm` on the last child of current root * refactor help page generation using Termimad templates -* clear help background when terminal was resized +* clear help background when terminal was resized between redraws <a name="v0.10.2"></a> ### v0.10.2 - 2019-11-15 @@ -88,7 +88,7 @@ dependencies = [ [[package]] name = "broot" -version = "0.10.2" +version = "0.10.3" dependencies = [ "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1,6 +1,6 @@ [package] name = "broot" -version = "0.10.2" +version = "0.10.3" authors = ["dystroy <denys.seguret@gmail.com>"] repository = "https://github.com/Canop/broot" documentation = "https://dystroy.org/broot" 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(()) |