Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly handle case where last character in a cancelled command begins a new command #6960

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move changes to handle_keymap_event
  • Loading branch information
Sam committed May 4, 2023
commit 497b7f3af8bf514a2156f88b38318b1b3b0befbd
25 changes: 11 additions & 14 deletions helix-term/src/ui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -830,17 +830,23 @@ impl EditorView {
last_mode = current_mode;
};

match &key_result {
match key_result {
KeymapResult::Matched(command) => {
execute_command(command);
execute_command(&command);
}
KeymapResult::Pending(node) => cxt.editor.autoinfo = Some(node.infobox()),
KeymapResult::MatchedSequence(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) {
pascalkuthe marked this conversation as resolved.
Show resolved Hide resolved
pending.pop();
}
return Some(KeymapResult::Cancelled(pending));
}
}
None
}
Expand All @@ -853,8 +859,7 @@ impl EditorView {
commands::insert::insert_char(cx, ch)
}
}
KeymapResult::Cancelled(mut pending) => {
let last_evt = pending.pop().unwrap();
KeymapResult::Cancelled(pending) => {
for ev in pending {
match ev.char() {
Some(ch) => commands::insert::insert_char(cx, ch),
Expand All @@ -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!(),
}
Expand Down
Loading