Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Fix ctrl-r with no register (#13184)

Conrad Irwin05c4c7872c81
diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.json
index a45b3a25d3e..621046e2b46 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 38b08a7d809..ad97a4af3d9 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 83eaa25f033..4f5ca7b558b 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 c61027157e3..6167bc3f334 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"}}