ui: dedup history suggestions in command execute bar

embed
Manos Pitsidianakis 2019-09-14 13:02:35 +03:00
parent 3ae2d03663
commit 2eb41f3d3d
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
1 changed files with 6 additions and 1 deletions

View File

@ -26,6 +26,7 @@ use super::*;
mod widgets;
pub use self::widgets::*;
use fnv::FnvHashSet;
/// A horizontally split in half container.
#[derive(Debug)]
@ -745,11 +746,15 @@ impl Component for StatusBar {
if self.ex_buffer.as_str().split_graphemes().len() <= 2 {
return;
}
let mut unique_suggestions: FnvHashSet<&str> = FnvHashSet::default();
let mut suggestions: Vec<AutoCompleteEntry> = self
.cmd_history
.iter()
.filter_map(|h| {
if h.starts_with(self.ex_buffer.as_str()) {
let sug = self.ex_buffer.as_str();
if h.starts_with(sug) && !unique_suggestions.contains(sug) {
unique_suggestions.insert(sug);
Some(h.clone().into())
} else {
None