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