Move changes to handle_keymap_event

pull/6960/head
Sam 2 years ago
parent df52fea84b
commit 497b7f3af8

@ -830,17 +830,23 @@ impl EditorView {
last_mode = current_mode; last_mode = current_mode;
}; };
match &key_result { match key_result {
KeymapResult::Matched(command) => { KeymapResult::Matched(command) => {
execute_command(command); execute_command(&command);
} }
KeymapResult::Pending(node) => cxt.editor.autoinfo = Some(node.infobox()), KeymapResult::Pending(node) => cxt.editor.autoinfo = Some(node.infobox()),
KeymapResult::MatchedSequence(commands) => { KeymapResult::MatchedSequence(commands) => {
for command in commands { for command in commands {
execute_command(command); execute_command(&command);
} }
} }
KeymapResult::NotFound | KeymapResult::Cancelled(_) => return Some(key_result), KeymapResult::NotFound => return Some(key_result),
KeymapResult::Cancelled(mut pending) => {
if !matches!(self.keymaps.get(mode, event), KeymapResult::NotFound) {
pending.pop();
}
return Some(KeymapResult::Cancelled(pending));
}
} }
None None
} }
@ -853,8 +859,7 @@ impl EditorView {
commands::insert::insert_char(cx, ch) commands::insert::insert_char(cx, ch)
} }
} }
KeymapResult::Cancelled(mut pending) => { KeymapResult::Cancelled(pending) => {
let last_evt = pending.pop().unwrap();
for ev in pending { for ev in pending {
match ev.char() { match ev.char() {
Some(ch) => commands::insert::insert_char(cx, ch), Some(ch) => commands::insert::insert_char(cx, ch),
@ -867,14 +872,6 @@ impl EditorView {
} }
} }
} }
match self.handle_keymap_event(Mode::Insert, cx, last_evt) {
Some(KeymapResult::NotFound) => {
if let Some(ch) = last_evt.char() {
commands::insert::insert_char(cx, ch)
}
}
_ => (),
}
} }
_ => unreachable!(), _ => unreachable!(),
} }

Loading…
Cancel
Save