@@ -35,6 +35,7 @@ impl Prompt {
35 self.line.insert(self.cursor, c);
35 self.line.insert(self.cursor, c);
36 self.cursor += 1;
36 self.cursor += 1;
37 self.completion = (self.completion_fn)(&self.line);
37 self.completion = (self.completion_fn)(&self.line);
38+ self.exit_selection();
40 pub fn move_char_left(&mut self) {
41 pub fn move_char_left(&mut self) {
@@ -63,6 +64,7 @@ impl Prompt {
63 self.cursor -= 1;
64 self.cursor -= 1;
64 self.completion = (self.completion_fn)(&self.line);
65 self.completion = (self.completion_fn)(&self.line);
67+ self.exit_selection();
68 pub fn change_completion_selection(&mut self) {
70 pub fn change_completion_selection(&mut self) {
@@ -75,7 +77,18 @@ impl Prompt {
78− .or(Some(0))
80+ .or(Some(0));
81+ self.line = String::from(
85+ .get(self.completion_selection_index.unwrap())
90+ pub fn exit_selection(&mut self) {
91+ self.completion_selection_index = None;
81 pub fn handle_input(&mut self, key_event: KeyEvent, editor: &mut Editor) {
94 pub fn handle_input(&mut self, key_event: KeyEvent, editor: &mut Editor) {
@@ -105,7 +118,7 @@ impl Prompt {
105 } => self.move_start(),
118 } => self.move_start(),
106 KeyEvent {
119 KeyEvent {
107 code: KeyCode::Backspace,
120 code: KeyCode::Backspace,
108− ..
121+ modifiers: KeyModifiers::NONE,
109 } => self.delete_char_backwards(),
122 } => self.delete_char_backwards(),
110 KeyEvent {
123 KeyEvent {
111 code: KeyCode::Enter,
124 code: KeyCode::Enter,
@@ -114,6 +127,10 @@ impl Prompt {
114 KeyEvent {
127 KeyEvent {
115 code: KeyCode::Tab, ..
128 code: KeyCode::Tab, ..
116 } => self.change_completion_selection(),
129 } => self.change_completion_selection(),
131+ code: KeyCode::Char('q'),
132+ modifiers: KeyModifiers::CONTROL,
133+ } => self.exit_selection(),