diff options
author | Canop <cano.petrole@gmail.com> | 2020-01-23 21:29:50 +0100 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2020-01-23 21:29:50 +0100 |
commit | bb99e01750f09292a0f1a822afc95815047c31a8 (patch) | |
tree | b88333b014b108737b0f1660ec8fddfe8714dfa8 | |
parent | 2e20f83ed40da81782ef7123f80afe4ae9820f52 (diff) |
TAB key now jumps to direct matches only
It was equivalent to the down key, which made it useless
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | src/browser_states.rs | 6 | ||||
-rw-r--r-- | src/flat_tree.rs | 7 |
3 files changed, 10 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 53347a2..219b08c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ### master - fix panic on input being "///" (Fix #175) +- TAB key now jumps to direct matches only <a name="v0.12.0"></a> ### v0.12.0 - 2020-01-19 diff --git a/src/browser_states.rs b/src/browser_states.rs index e93c323..a0f4853 100644 --- a/src/browser_states.rs +++ b/src/browser_states.rs @@ -346,10 +346,8 @@ impl AppState for BrowserState { Command::new(), )), Action::Next => { - if let Some(tree) = &mut self.filtered_tree { - tree.try_select_next_match(); - tree.make_selection_visible(page_height); - } + self.displayed_tree_mut().try_select_next_match(); + self.displayed_tree_mut().make_selection_visible(page_height); Ok(AppStateCmdResult::Keep) } Action::Previous => { diff --git a/src/flat_tree.rs b/src/flat_tree.rs index 18d2930..5921c42 100644 --- a/src/flat_tree.rs +++ b/src/flat_tree.rs @@ -406,6 +406,13 @@ impl Tree { if !line.is_selectable() { continue; } + // Not very elegant + // If we implement several types of search (path, content), + // we'll rather store a direct_match boolean in the line. + if self.options.pattern.is_some() + && self.options.pattern.score_of(&line.name).is_none() { + continue; + } if line.score > 0 { self.selection = idx; return true; |