diff options
author | Canop <cano.petrole@gmail.com> | 2021-06-13 17:43:21 +0200 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2021-06-13 17:43:21 +0200 |
commit | 7611a5166ce63b735e9d2dad5bee8fdd570336ba (patch) | |
tree | adf8ff6905368406cde2728851ae061a01b6f837 /src/browser | |
parent | dec7324fd505e41decf152492ae4942ffed36db0 (diff) |
try to keep selection on tree option change
Diffstat (limited to 'src/browser')
-rw-r--r-- | src/browser/browser_state.rs | 8 |
1 files changed, 7 insertions, 1 deletions
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, ) } |