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
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Make recursive call, add (nonworking) test cases
  • Loading branch information
Sam committed May 7, 2023
commit 9a421171220cb5944f3097bc72369e8fd5850e78
5 changes: 4 additions & 1 deletion helix-term/src/ui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,10 @@ impl EditorView {
}
KeymapResult::NotFound => return Some(key_result),
KeymapResult::Cancelled(mut pending) => {
if !matches!(self.keymaps.get(mode, event), KeymapResult::NotFound) {
if !matches!(
self.handle_keymap_event(mode, cxt, event),
Some(KeymapResult::NotFound)
) {
pending.pop();
}
return Some(KeymapResult::Cancelled(pending));
Expand Down
17 changes: 17 additions & 0 deletions helix-term/tests/test/movement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,23 @@ async fn cursor_position_append_eof() -> anyhow::Result<()> {
Ok(())
}

#[tokio::test(flavor = "multi_thread")]
async fn repeated_key_movement() -> anyhow::Result<()> {
test((
"#[|f]#oo",
"]]<space>",
helpers::platform_line("#[|f]#oo\n"),
))
.await?;
test((
"#[|f]#oo\n\nbar",
"]]p",
helpers::platform_line("#[foo\n|]#\nbar"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, a quick workaround for this would just be too add another \n, or express this with a multi line string literal.

))
.await?;
Ok(())
}

#[tokio::test(flavor = "multi_thread")]
async fn select_mode_tree_sitter_next_function_is_union_of_objects() -> anyhow::Result<()> {
test_with_config(
Expand Down