@@ -584,7 +584,6 @@ impl Component for EditorView {
584 if completion.is_empty() {
584 if completion.is_empty() {
585 self.completion = None;
585 self.completion = None;
587− // TODO: if exiting InsertMode, remove completion
@@ -605,16 +604,24 @@ impl Component for EditorView {
605 let (view, doc) = cx.editor.current();
604 let (view, doc) = cx.editor.current();
606 view.ensure_cursor_in_view(doc);
605 view.ensure_cursor_in_view(doc);
608− if mode == Mode::Normal && doc.mode() == Mode::Insert {
607+ // mode transitions
608+ match (mode, doc.mode()) {
609+ (Mode::Normal, Mode::Insert) => {
609− // HAXX: if we just entered insert mode from normal, clear key buf
610+ // HAXX: if we just entered insert mode from normal, clear key buf
610− // and record the command that got us into this mode.
611+ // and record the command that got us into this mode.
612− // how we entered insert mode is important, and we should track that so
613+ // how we entered insert mode is important, and we should track that so
613− // we can repeat the side effect.
614+ // we can repeat the side effect.
615− self.last_insert.0 = self.keymap[&mode][&key];
616+ self.last_insert.0 = self.keymap[&mode][&key];
616− self.last_insert.1.clear();
617+ self.last_insert.1.clear();
619+ (Mode::Insert, Mode::Normal) => {
620+ // if exiting insert mode, remove completion
621+ self.completion = None;
619 EventResult::Consumed(callback)
626 EventResult::Consumed(callback)