From 32605e9ea4d9c1de2b23ac084d30df5c36b5f4dc Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Thu, 26 Sep 2024 20:27:49 -0600 Subject: [PATCH] Fix register selection in visual mode (#18418) Related to #12895 Release Notes: - vim: Fix register selection in visual yank --- crates/vim/src/normal/mark.rs | 1 - crates/vim/src/normal/paste.rs | 3 +++ crates/vim/test_data/test_special_registers.json | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/vim/src/normal/mark.rs b/crates/vim/src/normal/mark.rs index 787430e747e3f20509e6887595e6aaf3077a0b65..743ab59ee286cc6a57de39f7fc65bb82a2bbee51 100644 --- a/crates/vim/src/normal/mark.rs +++ b/crates/vim/src/normal/mark.rs @@ -63,7 +63,6 @@ impl Vim { self.marks.insert("<".to_string(), starts); self.marks.insert(">".to_string(), ends); self.stored_visual_mode.replace((mode, reversed)); - self.clear_operator(cx); } pub fn jump(&mut self, text: Arc, line: bool, cx: &mut ViewContext) { diff --git a/crates/vim/src/normal/paste.rs b/crates/vim/src/normal/paste.rs index 05469dbf9f168fe0e75519476d8710fd6787adfc..5322f913c1769b1468597bf8411c17c83ebf59bc 100644 --- a/crates/vim/src/normal/paste.rs +++ b/crates/vim/src/normal/paste.rs @@ -673,6 +673,9 @@ mod test { cx.simulate_shared_keystrokes("\" _ d d").await; cx.shared_register('_').await.assert_eq(""); + cx.simulate_shared_keystrokes("shift-v \" _ y w").await; + cx.shared_register('"').await.assert_eq("jumps"); + cx.shared_state().await.assert_eq(indoc! {" The quick brown the ˇlazy dog"}); diff --git a/crates/vim/test_data/test_special_registers.json b/crates/vim/test_data/test_special_registers.json index 8b6b098af659fd6048f2be329bbf9e5c36563607..35f181a05c4f64cc0e70099b39e9b63ed6cdd30b 100644 --- a/crates/vim/test_data/test_special_registers.json +++ b/crates/vim/test_data/test_special_registers.json @@ -10,6 +10,13 @@ {"Key":"d"} {"Get":{"state":"The quick brown\nthe ˇlazy dog","mode":"Normal"}} {"ReadRegister":{"name":"_","value":""}} +{"Key":"shift-v"} +{"Key":"\""} +{"Key":"_"} +{"Key":"y"} +{"Key":"w"} +{"Get":{"state":"The quick brown\nthe ˇlazy dog","mode":"Normal"}} +{"ReadRegister":{"name":"\"","value":"jumps"}} {"Get":{"state":"The quick brown\nthe ˇlazy dog","mode":"Normal"}} {"Key":"\""} {"Key":"\""}