aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui/editor.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-05-29 01:37:47 +0000
committerBlaž Hrastnik2021-05-29 01:37:47 +0000
commitd54ae09d3b7a5eb56050631a58e75a1d1686ea70 (patch)
tree89f8c5079c43f026156d756df6c0325fe16083bc /helix-term/src/ui/editor.rs
parenta28eaa81a0c5fede1e34aca5bbf70d411f7a174b (diff)
ESC should exit both completion and insert mode
Diffstat (limited to 'helix-term/src/ui/editor.rs')
-rw-r--r--helix-term/src/ui/editor.rs25
1 files changed, 16 insertions, 9 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index c597f840..47770ebd 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -584,7 +584,6 @@ impl Component for EditorView {
if completion.is_empty() {
self.completion = None;
}
- // TODO: if exiting InsertMode, remove completion
}
}
}
@@ -605,16 +604,24 @@ impl Component for EditorView {
let (view, doc) = cx.editor.current();
view.ensure_cursor_in_view(doc);
- if mode == Mode::Normal && doc.mode() == Mode::Insert {
- // HAXX: if we just entered insert mode from normal, clear key buf
- // and record the command that got us into this mode.
+ // mode transitions
+ match (mode, doc.mode()) {
+ (Mode::Normal, Mode::Insert) => {
+ // HAXX: if we just entered insert mode from normal, clear key buf
+ // and record the command that got us into this mode.
- // how we entered insert mode is important, and we should track that so
- // we can repeat the side effect.
+ // how we entered insert mode is important, and we should track that so
+ // we can repeat the side effect.
- self.last_insert.0 = self.keymap[&mode][&key];
- self.last_insert.1.clear();
- };
+ self.last_insert.0 = self.keymap[&mode][&key];
+ self.last_insert.1.clear();
+ }
+ (Mode::Insert, Mode::Normal) => {
+ // if exiting insert mode, remove completion
+ self.completion = None;
+ }
+ _ => (),
+ }
EventResult::Consumed(callback)
}