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.

vim: Fix `gr` in visual mode (#25301)

0x2CA6b9397c38028
diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.json
index 211cbcf9266..238ba4ffe5f 100644
--- a/assets/keymaps/vim.json
+++ b/assets/keymaps/vim.json
@@ -293,6 +293,7 @@
"!": "vim::ShellCommand",
"i": ["vim::PushObject", { "around": false }],
"a": ["vim::PushObject", { "around": true }],
+ "g r": ["vim::Paste", { "preserve_clipboard": true }],
"g c": "vim::ToggleComments",
"g q": "vim::Rewrap",
"\"": "vim::PushRegister",
diff --git a/crates/vim/src/normal/paste.rs b/crates/vim/src/normal/paste.rs
index 849fa968c87..ea0e57315fc 100644
--- a/crates/vim/src/normal/paste.rs
+++ b/crates/vim/src/normal/paste.rs
@@ -849,6 +849,26 @@ mod test {
);
let clipboard: Register = cx.read_from_clipboard().unwrap().into();
assert_eq!(clipboard.text, "fish");
+
+ cx.set_state(
+ indoc! {"
+ ˇfish one
+ two three
+ "},
+ Mode::Normal,
+ );
+ cx.simulate_keystrokes("y i w");
+ cx.simulate_keystrokes("w");
+ cx.simulate_keystrokes("v i w g r");
+ cx.assert_state(
+ indoc! {"
+ fish fisˇh
+ two three
+ "},
+ Mode::Normal,
+ );
+ let clipboard: Register = cx.read_from_clipboard().unwrap().into();
+ assert_eq!(clipboard.text, "fish");
}
#[gpui::test]