diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.json index a45b3a25d3..621046e2b4 100644 --- a/assets/keymaps/vim.json +++ b/assets/keymaps/vim.json @@ -657,6 +657,13 @@ "ctrl-[": ["vim::SwitchMode", "Normal"] } }, + { + "context": "Editor && vim_mode == insert && VimWaiting", + "bindings": { + "escape": "vim::NormalBefore", + "ctrl-[": "vim::NormalBefore" + } + }, { "context": "BufferSearchBar && !in_replace", "bindings": { diff --git a/crates/vim/src/insert.rs b/crates/vim/src/insert.rs index 38b08a7d80..ad97a4af3d 100644 --- a/crates/vim/src/insert.rs +++ b/crates/vim/src/insert.rs @@ -124,5 +124,9 @@ mod test { cx.set_shared_state("heˇllo\n").await; cx.simulate_shared_keystrokes("y y i ctrl-r \"").await; cx.shared_state().await.assert_eq("hehello\nˇllo\n"); + + cx.simulate_shared_keystrokes("ctrl-r x ctrl-r escape") + .await; + cx.shared_state().await.assert_eq("hehello\nˇllo\n"); } } diff --git a/crates/vim/src/vim.rs b/crates/vim/src/vim.rs index 83eaa25f03..4f5ca7b558 100644 --- a/crates/vim/src/vim.rs +++ b/crates/vim/src/vim.rs @@ -896,6 +896,7 @@ impl Vim { ) } }); + vim.clear_operator(cx); } _ => { vim.select_register(text, cx); diff --git a/crates/vim/test_data/test_insert_ctrl_r.json b/crates/vim/test_data/test_insert_ctrl_r.json index c61027157e..6167bc3f33 100644 --- a/crates/vim/test_data/test_insert_ctrl_r.json +++ b/crates/vim/test_data/test_insert_ctrl_r.json @@ -5,3 +5,8 @@ {"Key":"ctrl-r"} {"Key":"\""} {"Get":{"state":"hehello\nˇllo\n","mode":"Insert"}} +{"Key":"ctrl-r"} +{"Key":"x"} +{"Key":"ctrl-r"} +{"Key":"escape"} +{"Get":{"state":"hehello\nˇllo\n","mode":"Insert"}}