diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | src/browser/browser_state.rs | 8 |
2 files changed, 8 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index aefc041..a91b1ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - `{root}` argument (current tree root) can be used in verb patterns - `working_dir` verb attribute - client-server mode fixed, no longer feature-gated (but still only available on unix like systems) +- broot tries to keep same selection on option changes <a name="v1.5.1"></a> ### v1.5.1 - 2021-06-03 diff --git a/src/browser/browser_state.rs b/src/browser/browser_state.rs index 70d8eec..a136514 100644 --- a/src/browser/browser_state.rs +++ b/src/browser/browser_state.rs @@ -205,8 +205,14 @@ impl PanelState for BrowserState { let tree = self.displayed_tree(); let mut options = tree.options.clone(); change_options(&mut options); + let mut new_state = BrowserState::new(tree.root().clone(), options, screen, con, &Dam::unlimited()); + if let Ok(Some(bs)) = &mut new_state { + if tree.selection != 0 { + bs.displayed_tree_mut().try_select_path(&tree.selected_line().path); + } + } CmdResult::from_optional_state( - BrowserState::new(tree.root().clone(), options, screen, con, &Dam::unlimited()), + new_state, in_new_panel, ) } |