From 14289b5a6eff98c7e533ab8c651f96d4c282ea2c Mon Sep 17 00:00:00 2001 From: xzbdmw <97848247+xzbdmw@users.noreply.github.com> Date: Sat, 15 Feb 2025 12:32:21 +0800 Subject: [PATCH] Fix ReplaceWithRegister with proper dot repeat (#24932) Release Notes: - Fixed ReplaceWithRegister with proper dot repeat --- crates/vim/src/normal/paste.rs | 31 +++++++++++++++++++++++++++++++ crates/vim/src/vim.rs | 1 + 2 files changed, 32 insertions(+) diff --git a/crates/vim/src/normal/paste.rs b/crates/vim/src/normal/paste.rs index 417a4aa67e..261b137b14 100644 --- a/crates/vim/src/normal/paste.rs +++ b/crates/vim/src/normal/paste.rs @@ -850,4 +850,35 @@ mod test { let clipboard: Register = cx.read_from_clipboard().unwrap().into(); assert_eq!(clipboard.text, "fish"); } + + #[gpui::test] + async fn test_replace_with_register_dot_repeat(cx: &mut gpui::TestAppContext) { + let mut cx = VimTestContext::new(cx, true).await; + + cx.set_state( + indoc! {" + ˇfish one + two three + "}, + Mode::Normal, + ); + cx.simulate_keystrokes("y i w"); + cx.simulate_keystrokes("w"); + cx.simulate_keystrokes("g r i w"); + cx.assert_state( + indoc! {" + fish fisˇh + two three + "}, + Mode::Normal, + ); + cx.simulate_keystrokes("j ."); + cx.assert_state( + indoc! {" + fish fish + two fisˇh + "}, + Mode::Normal, + ); + } } diff --git a/crates/vim/src/vim.rs b/crates/vim/src/vim.rs index 2417bdbc40..f6f77f6dd2 100644 --- a/crates/vim/src/vim.rs +++ b/crates/vim/src/vim.rs @@ -825,6 +825,7 @@ impl Vim { | Operator::Uppercase | Operator::OppositeCase | Operator::ToggleComments + | Operator::ReplaceWithRegister ) { self.start_recording(cx) };