vim: Fix blackhole register (#17419)

Closes: #17306

Release Notes:

- vim: Fixed `"_` register writes overwriting `"` register.
This commit is contained in:
Conrad Irwin 2024-09-05 11:19:02 -06:00 committed by GitHub
parent 1e09884a22
commit a7c46206de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 27 additions and 4 deletions

View file

@ -218,23 +218,25 @@ impl VimGlobals {
let yanked = current.clone(); let yanked = current.clone();
self.registers.insert('"', yanked); self.registers.insert('"', yanked);
} else { } else {
self.registers.insert('"', content.clone());
match lower { match lower {
'_' | ':' | '.' | '%' | '#' | '=' | '/' => {} '_' | ':' | '.' | '%' | '#' | '=' | '/' => {}
'+' => { '+' => {
self.registers.insert('"', content.clone());
cx.write_to_clipboard(content.into()); cx.write_to_clipboard(content.into());
} }
'*' => { '*' => {
self.registers.insert('"', content.clone());
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
cx.write_to_primary(content.into()); cx.write_to_primary(content.into());
#[cfg(not(target_os = "linux"))] #[cfg(not(target_os = "linux"))]
cx.write_to_clipboard(content.into()); cx.write_to_clipboard(content.into());
} }
'"' => { '"' => {
self.registers.insert('0', content.clone()); self.registers.insert('"', content.clone());
self.registers.insert('"', content); self.registers.insert('0', content);
} }
_ => { _ => {
self.registers.insert('"', content.clone());
self.registers.insert(lower, content); self.registers.insert(lower, content);
} }
} }

View file

@ -1424,7 +1424,17 @@ async fn test_record_replay_recursion(cx: &mut gpui::TestAppContext) {
cx.simulate_shared_keystrokes(".").await; cx.simulate_shared_keystrokes(".").await;
cx.simulate_shared_keystrokes(".").await; cx.simulate_shared_keystrokes(".").await;
cx.simulate_shared_keystrokes(".").await; cx.simulate_shared_keystrokes(".").await;
cx.shared_state().await.assert_eq("ˇhello world"); // takes a _long_ time cx.shared_state().await.assert_eq("ˇhello world");
}
#[gpui::test]
async fn test_blackhole_register(cx: &mut gpui::TestAppContext) {
let mut cx = NeovimBackedTestContext::new(cx).await;
cx.set_shared_state("ˇhello world").await;
cx.simulate_shared_keystrokes("d i w \" _ d a w").await;
cx.simulate_shared_keystrokes("p").await;
cx.shared_state().await.assert_eq("hellˇo");
} }
#[gpui::test] #[gpui::test]

View file

@ -0,0 +1,11 @@
{"Put":{"state":"ˇhello world"}}
{"Key":"d"}
{"Key":"i"}
{"Key":"w"}
{"Key":"\""}
{"Key":"_"}
{"Key":"d"}
{"Key":"a"}
{"Key":"w"}
{"Key":"p"}
{"Get":{"state":"hellˇo","mode":"Normal"}}