From 6b9397c380280899573f62ea5e4c140842eaee67 Mon Sep 17 00:00:00 2001 From: 0x2CA <2478557459@qq.com> Date: Fri, 21 Feb 2025 14:39:11 +0800 Subject: [PATCH] vim: Fix `gr` in visual mode (#25301) Closes #25258 Release Notes: - Fixed `gr` in visual mode --- assets/keymaps/vim.json | 1 + crates/vim/src/normal/paste.rs | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.json index 211cbcf9266f0a..238ba4ffe5f464 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 849fa968c87ef1..ea0e57315fcdfd 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]