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 clear exchange not working (#25804)

Thomas Heartman82338e2c477a
diff --git a/crates/vim/src/replace.rs b/crates/vim/src/replace.rs
index 77f8af1f475..ada0194f0e8 100644
--- a/crates/vim/src/replace.rs
+++ b/crates/vim/src/replace.rs
@@ -170,8 +170,9 @@ impl Vim {
pub fn clear_exchange(&mut self, window: &mut Window, cx: &mut Context<Self>) {
self.stop_recording(cx);
self.update_editor(window, cx, |_, editor, _, cx| {
- editor.clear_highlights::<VimExchange>(cx);
+ editor.clear_background_highlights::<VimExchange>(cx);
});
+ self.clear_operator(window, cx);
}
pub fn exchange_motion(
@@ -483,4 +484,27 @@ mod test {
cx.simulate_keystrokes("c x t r w c x i w");
cx.assert_state("hello ˇworld", Mode::Normal);
}
+
+ #[gpui::test]
+ async fn test_clear_exchange_clears_operator(cx: &mut gpui::TestAppContext) {
+ let mut cx = VimTestContext::new(cx, true).await;
+
+ cx.set_state("ˇirrelevant", Mode::Normal);
+ cx.simulate_keystrokes("c x c");
+
+ assert_eq!(cx.active_operator(), None);
+ }
+
+ #[gpui::test]
+ async fn test_clear_exchange(cx: &mut gpui::TestAppContext) {
+ let mut cx = VimTestContext::new(cx, true).await;
+
+ cx.set_state("ˇhello world", Mode::Normal);
+ cx.simulate_keystrokes("c x i w c x c");
+
+ cx.update_editor(|editor, window, cx| {
+ let highlights = editor.all_text_background_highlights(window, cx);
+ assert_eq!(0, highlights.len());
+ });
+ }
}