diff options
author | Canop <cano.petrole@gmail.com> | 2020-06-10 20:34:53 +0200 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2020-06-10 21:00:33 +0200 |
commit | 3f2804813851b18450c9aa8f619536acb94f411a (patch) | |
tree | 6aae0662b70386f8f8043badd5aed2a5c41634e0 /src/browser/browser_state.rs | |
parent | 652c3b3824acf1ecfc43a2fe357f419b4ec0a9ba (diff) |
:open_stay_filter : like :open_stay but keeping the pattern
It can be bound to a new key or even defined as an alternative
to :open_stay with:
```
[[verbs]]
key = "enter"
execution = ":open_stay_filter"
```
Fix #220
Diffstat (limited to 'src/browser/browser_state.rs')
-rw-r--r-- | src/browser/browser_state.rs | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/browser/browser_state.rs b/src/browser/browser_state.rs index c49d50e..e57d905 100644 --- a/src/browser/browser_state.rs +++ b/src/browser/browser_state.rs @@ -105,6 +105,7 @@ impl BrowserState { screen: &mut Screen, con: &AppContext, in_new_panel: bool, + keep_pattern: bool, ) -> Result<AppStateCmdResult, ProgramError> { let tree = self.displayed_tree(); let line = tree.selected_line(); @@ -127,7 +128,17 @@ impl BrowserState { } let dam = Dam::unlimited(); Ok(AppStateCmdResult::from_optional_state( - BrowserState::new(target, tree.options.without_pattern(), screen, con, &dam), + BrowserState::new( + target, + if keep_pattern { + tree.options.clone() + } else { + tree.options.without_pattern() + }, + screen, + con, + &dam, + ), in_new_panel, )) } @@ -332,7 +343,7 @@ impl AppState for BrowserState { con: &AppContext, ) -> Result<AppStateCmdResult, ProgramError> { if self.displayed_tree().selection == y as usize { - self.open_selection_stay_in_broot(screen, con, false) + self.open_selection_stay_in_broot(screen, con, false, false) } else { // A double click always come after a simple click at // same position. If it's not the selected line, it means @@ -415,7 +426,8 @@ impl AppState for BrowserState { AppStateCmdResult::NewState(Box::new(HelpState::new(screen, con))) } } - Internal::open_stay => self.open_selection_stay_in_broot(screen, con, bang)?, + Internal::open_stay => self.open_selection_stay_in_broot(screen, con, bang, false)?, + Internal::open_stay_filter => self.open_selection_stay_in_broot(screen, con, bang, true)?, Internal::open_leave => self.open_selection_quit_broot(con)?, Internal::line_down => { self.displayed_tree_mut().move_selection(1, page_height); |