diff options
-rw-r--r-- | src/app.rs | 5 | ||||
-rw-r--r-- | src/command.rs | 6 |
2 files changed, 7 insertions, 4 deletions
@@ -1042,7 +1042,10 @@ impl<'ctx> AppState<'ctx> { | |||
1042 | Keycode::Up => self.command_box.hist_prev(), | 1042 | Keycode::Up => self.command_box.hist_prev(), |
1043 | Keycode::Down => self.command_box.hist_next(), | 1043 | Keycode::Down => self.command_box.hist_next(), |
1044 | Keycode::Return => self.eval_command(), | 1044 | Keycode::Return => self.eval_command(), |
1045 | Keycode::Tab => self.command_box.complete_next(&self.lisp_env), | 1045 | Keycode::Tab if keymod == Mod::LSHIFTMOD => { |
1046 | self.command_box.complete(&self.lisp_env, true) | ||
1047 | } | ||
1048 | Keycode::Tab => self.command_box.complete(&self.lisp_env, false), | ||
1046 | Keycode::Escape => { | 1049 | Keycode::Escape => { |
1047 | self.command_box.clear(); | 1050 | self.command_box.clear(); |
1048 | self.message.text.clear(); | 1051 | self.message.text.clear(); |
diff --git a/src/command.rs b/src/command.rs index 26aeb05..6e9f900 100644 --- a/src/command.rs +++ b/src/command.rs | |||
@@ -224,14 +224,14 @@ impl CommandBox { | |||
224 | self.invalidate_completions(); | 224 | self.invalidate_completions(); |
225 | } | 225 | } |
226 | 226 | ||
227 | pub fn complete_next(&mut self, env_list: &[Environment]) { | 227 | pub fn complete(&mut self, env_list: &[Environment], reverse: bool) { |
228 | let c = self.cursor; | 228 | let c = self.cursor; |
229 | // completions exist, fill with next completion | 229 | // completions exist, fill with next completion |
230 | if let Some(cs) = &mut self.completions { | 230 | if let Some(cs) = &mut self.completions { |
231 | self.cursor = cs.trigger_idx; | 231 | self.cursor = cs.trigger_idx; |
232 | let prev_len = cs.get().len(); | 232 | let prev_len = cs.get().len(); |
233 | // skips over the first empty completion | 233 | // skips over the first empty completion |
234 | let new_insertion = cs.next(); | 234 | let new_insertion = if reverse { cs.prev() } else { cs.next() }; |
235 | self.text = format!( | 235 | self.text = format!( |
236 | "{}{}{}", | 236 | "{}{}{}", |
237 | &self.text[..self.cursor], | 237 | &self.text[..self.cursor], |
@@ -249,7 +249,7 @@ impl CommandBox { | |||
249 | .map(|&s| s.to_owned()) | 249 | .map(|&s| s.to_owned()) |
250 | .collect(), | 250 | .collect(), |
251 | )); | 251 | )); |
252 | self.complete_next(env_list) | 252 | self.complete(env_list, reverse) |
253 | } | 253 | } |
254 | } | 254 | } |
255 | } | 255 | } |