diff options
author | Canop <cano.petrole@gmail.com> | 2020-12-13 16:41:35 +0100 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2020-12-13 17:22:07 +0100 |
commit | 2c06c7ca0a580618d932325e15d8d40e7640f24d (patch) | |
tree | 5764d009d564a514a285426be6ce497cc65660c9 /src/command | |
parent | ee4f93f4919be4e716bb9b73476473bbc8bd7159 (diff) |
keep selection visible on unfiltering
The selection was sometimes scrolled away on unfiltering.
Also change some formatting.
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/completion.rs | 11 | ||||
-rw-r--r-- | src/command/panel_input.rs | 15 | ||||
-rw-r--r-- | src/command/parts.rs | 9 |
3 files changed, 14 insertions, 21 deletions
diff --git a/src/command/completion.rs b/src/command/completion.rs index 1b479a0..862395c 100644 --- a/src/command/completion.rs +++ b/src/command/completion.rs @@ -37,10 +37,7 @@ pub enum Completions { } impl Completions { - - fn from_list( - completions: Vec<String>, - ) -> Self { + fn from_list(completions: Vec<String>) -> Self { let mut iter = completions.iter(); let mut common: &str = match iter.next() { Some(s) => &s, @@ -83,9 +80,7 @@ impl Completions { sel: Selection<'_>, ) -> Self { match con.verb_store.search(start, Some(sel.stype)) { - PrefixSearchResult::NoMatch => { - Self::None - } + PrefixSearchResult::NoMatch => Self::None, PrefixSearchResult::Match(name, _) => { if start.len() >= name.len() { debug_assert!(name == start); @@ -123,7 +118,7 @@ impl Completions { if !name.starts_with(child_part) { continue; } - if name==child_part && entry.file_type()?.is_dir() { + if name == child_part && entry.file_type()?.is_dir() { name = "/".to_string(); } else { name.drain(0..child_part.len()); diff --git a/src/command/panel_input.rs b/src/command/panel_input.rs index c8081a7..a131ac2 100644 --- a/src/command/panel_input.rs +++ b/src/command/panel_input.rs @@ -1,10 +1,7 @@ use { super::*, crate::{ - app::{ - AppContext, - Selection, - }, + app::{AppContext, Selection}, display::W, errors::ProgramError, keys, @@ -90,11 +87,12 @@ impl PanelInput { Internal::input_go_word_right => self.input_field.move_word_right(), Internal::input_go_to_start => self.input_field.move_to_start(), Internal::input_go_to_end => self.input_field.move_to_end(), - #[cfg(feature="clipboard")] + #[cfg(feature = "clipboard")] Internal::input_paste => { match terminal_clipboard::get_string() { Ok(pasted) => { - for c in pasted.chars() + for c in pasted + .chars() .filter(|c| c.is_alphanumeric() || c.is_ascii_punctuation()) { self.input_field.put_char(c); @@ -190,7 +188,10 @@ impl PanelInput { } }; if let Some(added) = added { - let mut raw = self.input_before_cycle.as_ref().map_or(raw, |s| s.to_string()); + let mut raw = self + .input_before_cycle + .as_ref() + .map_or(raw, |s| s.to_string()); raw.push_str(&added); self.input_field.set_content(&raw); return Command::from_raw(raw, false); diff --git a/src/command/parts.rs b/src/command/parts.rs index 62ed2f7..814c296 100644 --- a/src/command/parts.rs +++ b/src/command/parts.rs @@ -11,7 +11,7 @@ use { #[derive(Debug, Clone)] pub struct CommandParts { pub raw_pattern: String, // may be empty - pub pattern: BeTree<PatternOperator, PatternParts>, // + pub pattern: BeTree<PatternOperator, PatternParts>, pub verb_invocation: Option<VerbInvocation>, // may be empty if user typed the separator but no char after } @@ -26,10 +26,7 @@ impl fmt::Display for CommandParts { } impl CommandParts { - - pub fn from( - mut raw: String, - ) -> Self { + pub fn from(mut raw: String) -> Self { //let mut verb_invocation: Option<String> = None; let mut invocation_start_pos: Option<usize> = None; let mut escaping = false; @@ -87,7 +84,7 @@ impl CommandParts { } let mut verb_invocation = None; if let Some(pos) = invocation_start_pos { - verb_invocation = Some(VerbInvocation::from(&raw[pos+1..])); + verb_invocation = Some(VerbInvocation::from(&raw[pos + 1..])); raw.truncate(pos); } CommandParts { |