From 2b44031929c490298cfc29cdd055ca4f22bf4645 Mon Sep 17 00:00:00 2001 From: Jan Hrastnik Date: Tue, 3 Nov 2020 10:57:12 +0100 Subject: various fixes --- helix-view/src/commands.rs | 4 ++++ helix-view/src/keymap.rs | 1 + helix-view/src/prompt.rs | 12 +++++------- 3 files changed, 10 insertions(+), 7 deletions(-) (limited to 'helix-view') diff --git a/helix-view/src/commands.rs b/helix-view/src/commands.rs index 905f4e10..1d7737f0 100644 --- a/helix-view/src/commands.rs +++ b/helix-view/src/commands.rs @@ -309,6 +309,10 @@ pub fn append_mode(view: &mut View, _count: usize) { // TODO: I, A, o and O can share a lot of the primitives. +pub fn command_mode(_view: &mut View, _count: usize) { + unimplemented!() +} + // calculate line numbers for each selection range fn selection_lines(state: &State) -> Vec { let mut lines = state diff --git a/helix-view/src/keymap.rs b/helix-view/src/keymap.rs index f70b9deb..69e6cabb 100644 --- a/helix-view/src/keymap.rs +++ b/helix-view/src/keymap.rs @@ -163,6 +163,7 @@ pub fn default() -> Keymaps { vec![key!('p')] => commands::paste, vec![key!('>')] => commands::indent, vec![key!('<')] => commands::unindent, + vec![key!(':')] => commands::command_mode, vec![Key { code: KeyCode::Esc, modifiers: Modifiers::NONE diff --git a/helix-view/src/prompt.rs b/helix-view/src/prompt.rs index 749e54d2..8186b476 100644 --- a/helix-view/src/prompt.rs +++ b/helix-view/src/prompt.rs @@ -6,17 +6,17 @@ pub struct Prompt { pub prompt: String, pub line: String, pub cursor: usize, - pub completion: Option>, + pub completion: Vec, pub should_close: bool, pub completion_selection_index: Option, - completion_fn: Box Option>>, + completion_fn: Box Vec>, callback_fn: Box, } impl Prompt { pub fn new( prompt: String, - mut completion_fn: impl FnMut(&str) -> Option> + 'static, + mut completion_fn: impl FnMut(&str) -> Vec + 'static, callback_fn: impl FnMut(&mut Editor, &str) + 'static, ) -> Prompt { Prompt { @@ -68,11 +68,11 @@ impl Prompt { } pub fn change_completion_selection(&mut self) { - if self.completion.is_some() { + if !self.completion.is_empty() { self.completion_selection_index = self .completion_selection_index .map(|i| { - if i == self.completion.as_ref().unwrap().len() - 1 { + if i == self.completion.len() - 1 { 0 } else { i + 1 @@ -81,8 +81,6 @@ impl Prompt { .or(Some(0)); self.line = String::from( self.completion - .as_ref() - .unwrap() .get(self.completion_selection_index.unwrap()) .unwrap(), ); -- cgit v1.2.3-70-g09d2