Update vim mode tests to use new marked text format

Max Brunsfeld created

Change summary

crates/editor/src/test.rs       |  47 ++--
crates/vim/src/insert.rs        |   4 
crates/vim/src/normal.rs        | 397 +++++++++++++++++-----------------
crates/vim/src/normal/change.rs | 148 ++++++------
crates/vim/src/normal/delete.rs | 158 ++++++------
crates/vim/src/vim.rs           |  18 
crates/vim/src/visual.rs        | 182 ++++++++--------
7 files changed, 480 insertions(+), 474 deletions(-)

Detailed changes

crates/editor/src/test.rs 🔗

@@ -1,34 +1,29 @@
-use std::{
-    any::TypeId,
-    ops::{Deref, DerefMut, Range},
-    sync::Arc,
+use crate::{
+    display_map::{DisplayMap, DisplaySnapshot, ToDisplayPoint},
+    multi_buffer::ToPointUtf16,
+    AnchorRangeExt, Autoscroll, DisplayPoint, Editor, EditorMode, MultiBuffer, ToPoint,
 };
-
 use anyhow::Result;
 use futures::{Future, StreamExt};
-use indoc::indoc;
-
 use gpui::{
     json, keymap::Keystroke, AppContext, ModelContext, ModelHandle, ViewContext, ViewHandle,
 };
-use language::{
-    point_to_lsp, Buffer, BufferSnapshot, FakeLspAdapter, Language, LanguageConfig, Selection,
-};
+use indoc::indoc;
+use language::{point_to_lsp, Buffer, BufferSnapshot, FakeLspAdapter, Language, LanguageConfig};
 use lsp::{notification, request};
 use project::Project;
 use settings::Settings;
+use std::{
+    any::TypeId,
+    ops::{Deref, DerefMut, Range},
+    sync::Arc,
+};
 use util::{
     assert_set_eq, set_eq,
     test::{generate_marked_text, marked_text, parse_marked_text},
 };
 use workspace::{pane, AppState, Workspace, WorkspaceHandle};
 
-use crate::{
-    display_map::{DisplayMap, DisplaySnapshot, ToDisplayPoint},
-    multi_buffer::ToPointUtf16,
-    AnchorRangeExt, Autoscroll, DisplayPoint, Editor, EditorMode, MultiBuffer, ToPoint,
-};
-
 #[cfg(test)]
 #[ctor::ctor]
 fn init_logger() {
@@ -258,11 +253,7 @@ impl<'a> EditorTestContext<'a> {
         assert_set_eq!(actual_ranges, expected_ranges);
     }
 
-    pub fn assert_editor_selections(&mut self, expected_selections: Vec<Selection<usize>>) {
-        let expected_selections = expected_selections
-            .into_iter()
-            .map(|s| s.range())
-            .collect::<Vec<_>>();
+    pub fn assert_editor_selections(&mut self, expected_selections: Vec<Range<usize>>) {
         let expected_marked_text =
             generate_marked_text(&self.buffer_text(), &expected_selections, true);
         self.assert_selections(expected_selections, expected_marked_text)
@@ -277,7 +268,13 @@ impl<'a> EditorTestContext<'a> {
             .editor
             .read_with(self.cx, |editor, cx| editor.selections.all::<usize>(cx))
             .into_iter()
-            .map(|s| s.range())
+            .map(|s| {
+                if s.reversed {
+                    s.end..s.start
+                } else {
+                    s.start..s.end
+                }
+            })
             .collect::<Vec<_>>();
         let actual_marked_text =
             generate_marked_text(&self.buffer_text(), &actual_selections, true);
@@ -285,11 +282,13 @@ impl<'a> EditorTestContext<'a> {
             panic!(
                 indoc! {"
                     Editor has unexpected selections.
+
                     Expected selections:
                     {}
+
                     Actual selections:
-                    {}",
-                },
+                    {}
+                "},
                 expected_marked_text, actual_marked_text,
             );
         }

crates/vim/src/insert.rs 🔗

@@ -34,9 +34,9 @@ mod test {
         cx.simulate_keystroke("i");
         assert_eq!(cx.mode(), Mode::Insert);
         cx.simulate_keystrokes(["T", "e", "s", "t"]);
-        cx.assert_editor_state("Test|");
+        cx.assert_editor_state("Testˇ");
         cx.simulate_keystroke("escape");
         assert_eq!(cx.mode(), Mode::Normal);
-        cx.assert_editor_state("Tes|t");
+        cx.assert_editor_state("Tesˇt");
     }
 }

crates/vim/src/normal.rs 🔗

@@ -297,7 +297,6 @@ fn paste(_: &mut Workspace, _: &Paste, cx: &mut ViewContext<Workspace>) {
 #[cfg(test)]
 mod test {
     use indoc::indoc;
-    use language::Selection;
     use util::test::marked_text;
 
     use crate::{
@@ -312,15 +311,15 @@ mod test {
     async fn test_h(cx: &mut gpui::TestAppContext) {
         let cx = VimTestContext::new(cx, true).await;
         let mut cx = cx.binding(["h"]);
-        cx.assert("The q|uick", "The |quick");
-        cx.assert("|The quick", "|The quick");
+        cx.assert("The qˇuick", "The ˇquick");
+        cx.assert("ˇThe quick", "ˇThe quick");
         cx.assert(
             indoc! {"
                 The quick
-                |brown"},
+                ˇbrown"},
             indoc! {"
                 The quick
-                |brown"},
+                ˇbrown"},
         );
     }
 
@@ -328,15 +327,15 @@ mod test {
     async fn test_backspace(cx: &mut gpui::TestAppContext) {
         let cx = VimTestContext::new(cx, true).await;
         let mut cx = cx.binding(["backspace"]);
-        cx.assert("The q|uick", "The |quick");
-        cx.assert("|The quick", "|The quick");
+        cx.assert("The qˇuick", "The ˇquick");
+        cx.assert("ˇThe quick", "ˇThe quick");
         cx.assert(
             indoc! {"
                 The quick
-                |brown"},
+                ˇbrown"},
             indoc! {"
                 The quick
-                |brown"},
+                ˇbrown"},
         );
     }
 
@@ -346,35 +345,35 @@ mod test {
         let mut cx = cx.binding(["j"]);
         cx.assert(
             indoc! {"
-                The |quick
+                The ˇquick
                 brown fox"},
             indoc! {"
                 The quick
-                brow|n fox"},
+                browˇn fox"},
         );
         cx.assert(
             indoc! {"
                 The quick
-                brow|n fox"},
+                browˇn fox"},
             indoc! {"
                 The quick
-                brow|n fox"},
+                browˇn fox"},
         );
         cx.assert(
             indoc! {"
-                The quic|k
+                The quicˇk
                 brown"},
             indoc! {"
                 The quick
-                brow|n"},
+                browˇn"},
         );
         cx.assert(
             indoc! {"
                 The quick
-                |brown"},
+                ˇbrown"},
             indoc! {"
                 The quick
-                |brown"},
+                ˇbrown"},
         );
     }
 
@@ -384,26 +383,26 @@ mod test {
         let mut cx = cx.binding(["k"]);
         cx.assert(
             indoc! {"
-                The |quick
+                The ˇquick
                 brown fox"},
             indoc! {"
-                The |quick
+                The ˇquick
                 brown fox"},
         );
         cx.assert(
             indoc! {"
                 The quick
-                brow|n fox"},
+                browˇn fox"},
             indoc! {"
-                The |quick
+                The ˇquick
                 brown fox"},
         );
         cx.assert(
             indoc! {"
                 The
-                quic|k"},
+                quicˇk"},
             indoc! {"
-                Th|e
+                Thˇe
                 quick"},
         );
     }
@@ -412,14 +411,14 @@ mod test {
     async fn test_l(cx: &mut gpui::TestAppContext) {
         let cx = VimTestContext::new(cx, true).await;
         let mut cx = cx.binding(["l"]);
-        cx.assert("The q|uick", "The qu|ick");
-        cx.assert("The quic|k", "The quic|k");
+        cx.assert("The qˇuick", "The quˇick");
+        cx.assert("The quicˇk", "The quicˇk");
         cx.assert(
             indoc! {"
-                The quic|k
+                The quicˇk
                 brown"},
             indoc! {"
-                The quic|k
+                The quicˇk
                 brown"},
         );
     }
@@ -428,42 +427,42 @@ mod test {
     async fn test_jump_to_line_boundaries(cx: &mut gpui::TestAppContext) {
         let cx = VimTestContext::new(cx, true).await;
         let mut cx = cx.binding(["$"]);
-        cx.assert("T|est test", "Test tes|t");
-        cx.assert("Test tes|t", "Test tes|t");
+        cx.assert("Tˇest test", "Test tesˇt");
+        cx.assert("Test tesˇt", "Test tesˇt");
         cx.assert(
             indoc! {"
-                The |quick
+                The ˇquick
                 brown"},
             indoc! {"
-                The quic|k
+                The quicˇk
                 brown"},
         );
         cx.assert(
             indoc! {"
-                The quic|k
+                The quicˇk
                 brown"},
             indoc! {"
-                The quic|k
+                The quicˇk
                 brown"},
         );
 
         let mut cx = cx.binding(["0"]);
-        cx.assert("Test |test", "|Test test");
-        cx.assert("|Test test", "|Test test");
+        cx.assert("Test ˇtest", "ˇTest test");
+        cx.assert("ˇTest test", "ˇTest test");
         cx.assert(
             indoc! {"
-                The |quick
+                The ˇquick
                 brown"},
             indoc! {"
-                |The quick
+                ˇThe quick
                 brown"},
         );
         cx.assert(
             indoc! {"
-                |The quick
+                ˇThe quick
                 brown"},
             indoc! {"
-                |The quick
+                ˇThe quick
                 brown"},
         );
     }
@@ -475,7 +474,7 @@ mod test {
 
         cx.assert(
             indoc! {"
-                The |quick
+                The ˇquick
                 
                 brown fox jumps
                 over the lazy dog"},
@@ -483,39 +482,39 @@ mod test {
                 The quick
                 
                 brown fox jumps
-                over| the lazy dog"},
+                overˇ the lazy dog"},
         );
         cx.assert(
             indoc! {"
                 The quick
                 
                 brown fox jumps
-                over| the lazy dog"},
+                overˇ the lazy dog"},
             indoc! {"
                 The quick
                 
                 brown fox jumps
-                over| the lazy dog"},
+                overˇ the lazy dog"},
         );
         cx.assert(
             indoc! {"
-            The qui|ck
+            The quiˇck
             
             brown"},
             indoc! {"
             The quick
             
-            brow|n"},
+            browˇn"},
         );
         cx.assert(
             indoc! {"
-            The qui|ck
+            The quiˇck
             
             "},
             indoc! {"
             The quick
             
-            |"},
+            ˇ"},
         );
     }
 
@@ -523,14 +522,14 @@ mod test {
     async fn test_w(cx: &mut gpui::TestAppContext) {
         let mut cx = VimTestContext::new(cx, true).await;
         let (_, cursor_offsets) = marked_text(indoc! {"
-            The |quick|-|brown
-            |
-            |
-            |fox_jumps |over
-            |th||e"});
+            The ˇquickˇ-ˇbrown
+            ˇ
+            ˇ
+            ˇfox_jumps ˇover
+            ˇthˇˇe"});
         cx.set_state(
             indoc! {"
-            |The quick-brown
+            ˇThe quick-brown
             
             
             fox_jumps over
@@ -540,19 +539,19 @@ mod test {
 
         for cursor_offset in cursor_offsets {
             cx.simulate_keystroke("w");
-            cx.assert_editor_selections(vec![Selection::from_offset(cursor_offset)]);
+            cx.assert_editor_selections(vec![cursor_offset..cursor_offset]);
         }
 
         // Reset and test ignoring punctuation
         let (_, cursor_offsets) = marked_text(indoc! {"
-            The |quick-brown
-            |
-            |
-            |fox_jumps |over
-            |th||e"});
+            The ˇquick-brown
+            ˇ
+            ˇ
+            ˇfox_jumps ˇover
+            ˇthˇˇe"});
         cx.set_state(
             indoc! {"
-            |The quick-brown
+            ˇThe quick-brown
             
             
             fox_jumps over
@@ -562,7 +561,7 @@ mod test {
 
         for cursor_offset in cursor_offsets {
             cx.simulate_keystroke("shift-w");
-            cx.assert_editor_selections(vec![Selection::from_offset(cursor_offset)]);
+            cx.assert_editor_selections(vec![cursor_offset..cursor_offset]);
         }
     }
 
@@ -570,14 +569,14 @@ mod test {
     async fn test_e(cx: &mut gpui::TestAppContext) {
         let mut cx = VimTestContext::new(cx, true).await;
         let (_, cursor_offsets) = marked_text(indoc! {"
-            Th|e quic|k|-brow|n
+            Thˇe quicˇkˇ-browˇn
             
             
-            fox_jump|s ove|r
-            th|e"});
+            fox_jumpˇs oveˇr
+            thˇe"});
         cx.set_state(
             indoc! {"
-            |The quick-brown
+            ˇThe quick-brown
             
             
             fox_jumps over
@@ -587,19 +586,19 @@ mod test {
 
         for cursor_offset in cursor_offsets {
             cx.simulate_keystroke("e");
-            cx.assert_editor_selections(vec![Selection::from_offset(cursor_offset)]);
+            cx.assert_editor_selections(vec![cursor_offset..cursor_offset]);
         }
 
         // Reset and test ignoring punctuation
         let (_, cursor_offsets) = marked_text(indoc! {"
-            Th|e quick-brow|n
+            Thˇe quick-browˇn
             
             
-            fox_jump|s ove|r
-            th||e"});
+            fox_jumpˇs oveˇr
+            thˇˇe"});
         cx.set_state(
             indoc! {"
-            |The quick-brown
+            ˇThe quick-brown
             
             
             fox_jumps over
@@ -608,7 +607,7 @@ mod test {
         );
         for cursor_offset in cursor_offsets {
             cx.simulate_keystroke("shift-e");
-            cx.assert_editor_selections(vec![Selection::from_offset(cursor_offset)]);
+            cx.assert_editor_selections(vec![cursor_offset..cursor_offset]);
         }
     }
 
@@ -616,45 +615,45 @@ mod test {
     async fn test_b(cx: &mut gpui::TestAppContext) {
         let mut cx = VimTestContext::new(cx, true).await;
         let (_, cursor_offsets) = marked_text(indoc! {"
-            ||The |quick|-|brown
-            |
-            |
-            |fox_jumps |over
-            |the"});
+            ˇˇThe ˇquickˇ-ˇbrown
+            ˇ
+            ˇ
+            ˇfox_jumps ˇover
+            ˇthe"});
         cx.set_state(
             indoc! {"
             The quick-brown
             
             
             fox_jumps over
-            th|e"},
+            thˇe"},
             Mode::Normal,
         );
 
         for cursor_offset in cursor_offsets.into_iter().rev() {
             cx.simulate_keystroke("b");
-            cx.assert_editor_selections(vec![Selection::from_offset(cursor_offset)]);
+            cx.assert_editor_selections(vec![cursor_offset..cursor_offset]);
         }
 
         // Reset and test ignoring punctuation
         let (_, cursor_offsets) = marked_text(indoc! {"
-            ||The |quick-brown
-            |
-            |
-            |fox_jumps |over
-            |the"});
+            ˇˇThe ˇquick-brown
+            ˇ
+            ˇ
+            ˇfox_jumps ˇover
+            ˇthe"});
         cx.set_state(
             indoc! {"
             The quick-brown
             
             
             fox_jumps over
-            th|e"},
+            thˇe"},
             Mode::Normal,
         );
         for cursor_offset in cursor_offsets.into_iter().rev() {
             cx.simulate_keystroke("shift-b");
-            cx.assert_editor_selections(vec![Selection::from_offset(cursor_offset)]);
+            cx.assert_editor_selections(vec![cursor_offset..cursor_offset]);
         }
     }
 
@@ -683,21 +682,21 @@ mod test {
                 The quick
             
                 brown fox jumps
-                over |the lazy dog"},
+                over ˇthe lazy dog"},
             indoc! {"
-                The q|uick
+                The qˇuick
             
                 brown fox jumps
                 over the lazy dog"},
         );
         cx.assert(
             indoc! {"
-                The q|uick
+                The qˇuick
             
                 brown fox jumps
                 over the lazy dog"},
             indoc! {"
-                The q|uick
+                The qˇuick
             
                 brown fox jumps
                 over the lazy dog"},
@@ -707,9 +706,9 @@ mod test {
                 The quick
             
                 brown fox jumps
-                over the la|zy dog"},
+                over the laˇzy dog"},
             indoc! {"
-                The quic|k
+                The quicˇk
             
                 brown fox jumps
                 over the lazy dog"},
@@ -719,9 +718,9 @@ mod test {
                 
             
                 brown fox jumps
-                over the la|zy dog"},
+                over the laˇzy dog"},
             indoc! {"
-                |
+                ˇ
             
                 brown fox jumps
                 over the lazy dog"},
@@ -733,31 +732,31 @@ mod test {
         let cx = VimTestContext::new(cx, true).await;
         let mut cx = cx.binding(["a"]).mode_after(Mode::Insert);
 
-        cx.assert("The q|uick", "The qu|ick");
-        cx.assert("The quic|k", "The quick|");
+        cx.assert("The qˇuick", "The quˇick");
+        cx.assert("The quicˇk", "The quickˇ");
     }
 
     #[gpui::test]
     async fn test_insert_end_of_line(cx: &mut gpui::TestAppContext) {
         let cx = VimTestContext::new(cx, true).await;
         let mut cx = cx.binding(["shift-a"]).mode_after(Mode::Insert);
-        cx.assert("The q|uick", "The quick|");
-        cx.assert("The q|uick ", "The quick |");
-        cx.assert("|", "|");
+        cx.assert("The qˇuick", "The quickˇ");
+        cx.assert("The qˇuick ", "The quick ˇ");
+        cx.assert("ˇ", "ˇ");
         cx.assert(
             indoc! {"
-                The q|uick
+                The qˇuick
                 brown fox"},
             indoc! {"
-                The quick|
+                The quickˇ
                 brown fox"},
         );
         cx.assert(
             indoc! {"
-                |
+                ˇ
                 The quick"},
             indoc! {"
-                |
+                ˇ
                 The quick"},
         );
     }
@@ -766,50 +765,50 @@ mod test {
     async fn test_jump_to_first_non_whitespace(cx: &mut gpui::TestAppContext) {
         let cx = VimTestContext::new(cx, true).await;
         let mut cx = cx.binding(["^"]);
-        cx.assert("The q|uick", "|The quick");
-        cx.assert(" The q|uick", " |The quick");
-        cx.assert("|", "|");
+        cx.assert("The qˇuick", "ˇThe quick");
+        cx.assert(" The qˇuick", " ˇThe quick");
+        cx.assert("ˇ", "ˇ");
         cx.assert(
             indoc! {"
-                The q|uick
+                The qˇuick
                 brown fox"},
             indoc! {"
-                |The quick
+                ˇThe quick
                 brown fox"},
         );
         cx.assert(
             indoc! {"
-                |
+                ˇ
                 The quick"},
             indoc! {"
-                |
+                ˇ
                 The quick"},
         );
         // Indoc disallows trailing whitspace.
-        cx.assert("   | \nThe quick", "   | \nThe quick");
+        cx.assert("   ˇ \nThe quick", "   ˇ \nThe quick");
     }
 
     #[gpui::test]
     async fn test_insert_first_non_whitespace(cx: &mut gpui::TestAppContext) {
         let cx = VimTestContext::new(cx, true).await;
         let mut cx = cx.binding(["shift-i"]).mode_after(Mode::Insert);
-        cx.assert("The q|uick", "|The quick");
-        cx.assert(" The q|uick", " |The quick");
-        cx.assert("|", "|");
+        cx.assert("The qˇuick", "ˇThe quick");
+        cx.assert(" The qˇuick", " ˇThe quick");
+        cx.assert("ˇ", "ˇ");
         cx.assert(
             indoc! {"
-                The q|uick
+                The qˇuick
                 brown fox"},
             indoc! {"
-                |The quick
+                ˇThe quick
                 brown fox"},
         );
         cx.assert(
             indoc! {"
-                |
+                ˇ
                 The quick"},
             indoc! {"
-                |
+                ˇ
                 The quick"},
         );
     }
@@ -820,20 +819,20 @@ mod test {
         let mut cx = cx.binding(["shift-d"]);
         cx.assert(
             indoc! {"
-                The q|uick
+                The qˇuick
                 brown fox"},
             indoc! {"
-                The |q
+                The ˇq
                 brown fox"},
         );
         cx.assert(
             indoc! {"
                 The quick
-                |
+                ˇ
                 brown fox"},
             indoc! {"
                 The quick
-                |
+                ˇ
                 brown fox"},
         );
     }
@@ -842,15 +841,15 @@ mod test {
     async fn test_x(cx: &mut gpui::TestAppContext) {
         let cx = VimTestContext::new(cx, true).await;
         let mut cx = cx.binding(["x"]);
-        cx.assert("|Test", "|est");
-        cx.assert("Te|st", "Te|t");
-        cx.assert("Tes|t", "Te|s");
+        cx.assert("ˇTest", "ˇest");
+        cx.assert("Teˇst", "Teˇt");
+        cx.assert("Tesˇt", "Teˇs");
         cx.assert(
             indoc! {"
-                Tes|t
+                Tesˇt
                 test"},
             indoc! {"
-                Te|s
+                Teˇs
                 test"},
         );
     }
@@ -859,16 +858,16 @@ mod test {
     async fn test_delete_left(cx: &mut gpui::TestAppContext) {
         let cx = VimTestContext::new(cx, true).await;
         let mut cx = cx.binding(["shift-x"]);
-        cx.assert("Te|st", "T|st");
-        cx.assert("T|est", "|est");
-        cx.assert("|Test", "|Test");
+        cx.assert("Teˇst", "Tˇst");
+        cx.assert("Tˇest", "ˇest");
+        cx.assert("ˇTest", "ˇTest");
         cx.assert(
             indoc! {"
                 Test
-                |test"},
+                ˇtest"},
             indoc! {"
                 Test
-                |test"},
+                ˇtest"},
         );
     }
 
@@ -878,78 +877,84 @@ mod test {
         let mut cx = cx.binding(["o"]).mode_after(Mode::Insert);
 
         cx.assert(
-            "|",
+            "ˇ",
             indoc! {"
                 
-                |"},
+                ˇ"},
         );
         cx.assert(
-            "The |quick",
+            "The ˇquick",
             indoc! {"
                 The quick
-                |"},
+                ˇ"},
         );
         cx.assert(
             indoc! {"
                 The quick
-                brown |fox
+                brown ˇfox
                 jumps over"},
             indoc! {"
                 The quick
                 brown fox
-                |
+                ˇ
                 jumps over"},
         );
         cx.assert(
             indoc! {"
                 The quick
                 brown fox
-                jumps |over"},
+                jumps ˇover"},
             indoc! {"
                 The quick
                 brown fox
                 jumps over
-                |"},
+                ˇ"},
         );
         cx.assert(
             indoc! {"
-                The q|uick
+                The qˇuick
                 brown fox
                 jumps over"},
             indoc! {"
                 The quick
-                |
+                ˇ
                 brown fox
                 jumps over"},
         );
         cx.assert(
             indoc! {"
                 The quick
-                |
+                ˇ
                 brown fox"},
             indoc! {"
                 The quick
                 
-                |
+                ˇ
                 brown fox"},
         );
         cx.assert(
             indoc! {"
-                fn test()
-                    println!(|);"},
+                fn test() {
+                    println!(ˇ);
+                }
+            "},
             indoc! {"
-                fn test()
+                fn test() {
                     println!();
-                    |"},
+                    ˇ
+                }
+            "},
         );
         cx.assert(
             indoc! {"
-                fn test(|)
-                    println!();"},
+                fn test(ˇ) {
+                    println!();
+                }"},
             indoc! {"
-                fn test()
-                |
-                    println!();"},
+                fn test() {
+                ˇ
+                    println!();
+                }"},
         );
     }
 
@@ -959,25 +964,25 @@ mod test {
         let mut cx = cx.binding(["shift-o"]).mode_after(Mode::Insert);
 
         cx.assert(
-            "|",
+            "ˇ",
             indoc! {"
-                |
+                ˇ
                 "},
         );
         cx.assert(
-            "The |quick",
+            "The ˇquick",
             indoc! {"
-                |
+                ˇ
                 The quick"},
         );
         cx.assert(
             indoc! {"
                 The quick
-                brown |fox
+                brown ˇfox
                 jumps over"},
             indoc! {"
                 The quick
-                |
+                ˇ
                 brown fox
                 jumps over"},
         );
@@ -985,20 +990,20 @@ mod test {
             indoc! {"
                 The quick
                 brown fox
-                jumps |over"},
+                jumps ˇover"},
             indoc! {"
                 The quick
                 brown fox
-                |
+                ˇ
                 jumps over"},
         );
         cx.assert(
             indoc! {"
-                The q|uick
+                The qˇuick
                 brown fox
                 jumps over"},
             indoc! {"
-                |
+                ˇ
                 The quick
                 brown fox
                 jumps over"},
@@ -1006,31 +1011,33 @@ mod test {
         cx.assert(
             indoc! {"
                 The quick
-                |
+                ˇ
                 brown fox"},
             indoc! {"
                 The quick
-                |
+                ˇ
                 
                 brown fox"},
         );
         cx.assert(
             indoc! {"
                 fn test()
-                    println!(|);"},
+                    println!(ˇ);"},
             indoc! {"
                 fn test()
-                    |
+                    ˇ
                     println!();"},
         );
         cx.assert(
             indoc! {"
-                fn test(|)
-                    println!();"},
+                fn test(ˇ) {
+                    println!();
+                }"},
             indoc! {"
-                |
-                fn test()
-                    println!();"},
+                ˇ
+                fn test() {
+                    println!();
+                }"},
         );
     }
 
@@ -1039,43 +1046,43 @@ mod test {
         let cx = VimTestContext::new(cx, true).await;
         let mut cx = cx.binding(["d", "d"]);
 
-        cx.assert("|", "|");
-        cx.assert("The |quick", "|");
+        cx.assert("ˇ", "ˇ");
+        cx.assert("The ˇquick", "ˇ");
         cx.assert(
             indoc! {"
                 The quick
-                brown |fox
+                brown ˇfox
                 jumps over"},
             indoc! {"
                 The quick
-                jumps |over"},
+                jumps ˇover"},
         );
         cx.assert(
             indoc! {"
                 The quick
                 brown fox
-                jumps |over"},
+                jumps ˇover"},
             indoc! {"
                 The quick
-                brown |fox"},
+                brown ˇfox"},
         );
         cx.assert(
             indoc! {"
-                The q|uick
+                The qˇuick
                 brown fox
                 jumps over"},
             indoc! {"
-                brown| fox
+                brownˇ fox
                 jumps over"},
         );
         cx.assert(
             indoc! {"
                 The quick
-                |
+                ˇ
                 brown fox"},
             indoc! {"
                 The quick
-                |brown fox"},
+                ˇbrown fox"},
         );
     }
 
@@ -1084,46 +1091,46 @@ mod test {
         let cx = VimTestContext::new(cx, true).await;
         let mut cx = cx.binding(["c", "c"]).mode_after(Mode::Insert);
 
-        cx.assert("|", "|");
-        cx.assert("The |quick", "|");
+        cx.assert("ˇ", "ˇ");
+        cx.assert("The ˇquick", "ˇ");
         cx.assert(
             indoc! {"
                 The quick
-                brown |fox
+                brown ˇfox
                 jumps over"},
             indoc! {"
                 The quick
-                |
+                ˇ
                 jumps over"},
         );
         cx.assert(
             indoc! {"
                 The quick
                 brown fox
-                jumps |over"},
+                jumps ˇover"},
             indoc! {"
                 The quick
                 brown fox
-                |"},
+                ˇ"},
         );
         cx.assert(
             indoc! {"
-                The q|uick
+                The qˇuick
                 brown fox
                 jumps over"},
             indoc! {"
-                |
+                ˇ
                 brown fox
                 jumps over"},
         );
         cx.assert(
             indoc! {"
                 The quick
-                |
+                ˇ
                 brown fox"},
             indoc! {"
                 The quick
-                |
+                ˇ
                 brown fox"},
         );
     }
@@ -1134,7 +1141,7 @@ mod test {
         cx.set_state(
             indoc! {"
                 The quick brown
-                fox ju|mps over
+                fox juˇmps over
                 the lazy dog"},
             Mode::Normal,
         );
@@ -1142,21 +1149,21 @@ mod test {
         cx.simulate_keystrokes(["d", "d"]);
         cx.assert_editor_state(indoc! {"
             The quick brown
-            the la|zy dog"});
+            the laˇzy dog"});
 
         cx.simulate_keystroke("p");
         cx.assert_state(
             indoc! {"
                 The quick brown
                 the lazy dog
-                |fox jumps over"},
+                ˇfox jumps over"},
             Mode::Normal,
         );
 
         cx.set_state(
             indoc! {"
                 The quick brown
-                fox [jump}s over
+                fox «jumpˇ»s over
                 the lazy dog"},
             Mode::Visual { line: false },
         );

crates/vim/src/normal/change.rs 🔗

@@ -84,16 +84,16 @@ mod test {
     async fn test_change_h(cx: &mut gpui::TestAppContext) {
         let cx = VimTestContext::new(cx, true).await;
         let mut cx = cx.binding(["c", "h"]).mode_after(Mode::Insert);
-        cx.assert("Te|st", "T|st");
-        cx.assert("T|est", "|est");
-        cx.assert("|Test", "|Test");
+        cx.assert("Teˇst", "Tˇst");
+        cx.assert("Tˇest", "ˇest");
+        cx.assert("ˇTest", "ˇTest");
         cx.assert(
             indoc! {"
                 Test
-                |test"},
+                ˇtest"},
             indoc! {"
                 Test
-                |test"},
+                ˇtest"},
         );
     }
 
@@ -101,111 +101,111 @@ mod test {
     async fn test_change_l(cx: &mut gpui::TestAppContext) {
         let cx = VimTestContext::new(cx, true).await;
         let mut cx = cx.binding(["c", "l"]).mode_after(Mode::Insert);
-        cx.assert("Te|st", "Te|t");
-        cx.assert("Tes|t", "Tes|");
+        cx.assert("Teˇst", "Teˇt");
+        cx.assert("Tesˇt", "Tesˇ");
     }
 
     #[gpui::test]
     async fn test_change_w(cx: &mut gpui::TestAppContext) {
         let cx = VimTestContext::new(cx, true).await;
         let mut cx = cx.binding(["c", "w"]).mode_after(Mode::Insert);
-        cx.assert("Te|st", "Te|");
-        cx.assert("T|est test", "T| test");
-        cx.assert("Test|  test", "Test|test");
+        cx.assert("Teˇst", "Teˇ");
+        cx.assert("Tˇest test", "Tˇ test");
+        cx.assert("Testˇ  test", "Testˇtest");
         cx.assert(
             indoc! {"
-                Test te|st
+                Test teˇst
                 test"},
             indoc! {"
-                Test te|
+                Test teˇ
                 test"},
         );
         cx.assert(
             indoc! {"
-                Test tes|t
+                Test tesˇt
                 test"},
             indoc! {"
-                Test tes|
+                Test tesˇ
                 test"},
         );
         cx.assert(
             indoc! {"
                 Test test
-                |
+                ˇ
                 test"},
             indoc! {"
                 Test test
-                |
+                ˇ
                 test"},
         );
 
         let mut cx = cx.binding(["c", "shift-w"]);
-        cx.assert("Test te|st-test test", "Test te| test");
+        cx.assert("Test teˇst-test test", "Test teˇ test");
     }
 
     #[gpui::test]
     async fn test_change_e(cx: &mut gpui::TestAppContext) {
         let cx = VimTestContext::new(cx, true).await;
         let mut cx = cx.binding(["c", "e"]).mode_after(Mode::Insert);
-        cx.assert("Te|st Test", "Te| Test");
-        cx.assert("T|est test", "T| test");
+        cx.assert("Teˇst Test", "Teˇ Test");
+        cx.assert("Tˇest test", "Tˇ test");
         cx.assert(
             indoc! {"
-                Test te|st
+                Test teˇst
                 test"},
             indoc! {"
-                Test te|
+                Test teˇ
                 test"},
         );
         cx.assert(
             indoc! {"
-                Test tes|t
+                Test tesˇt
                 test"},
-            "Test tes|",
+            "Test tesˇ",
         );
         cx.assert(
             indoc! {"
                 Test test
-                |
+                ˇ
                 test"},
             indoc! {"
                 Test test
-                |
+                ˇ
                 test"},
         );
 
         let mut cx = cx.binding(["c", "shift-e"]);
-        cx.assert("Test te|st-test test", "Test te| test");
+        cx.assert("Test teˇst-test test", "Test teˇ test");
     }
 
     #[gpui::test]
     async fn test_change_b(cx: &mut gpui::TestAppContext) {
         let cx = VimTestContext::new(cx, true).await;
         let mut cx = cx.binding(["c", "b"]).mode_after(Mode::Insert);
-        cx.assert("Te|st Test", "|st Test");
-        cx.assert("Test |test", "|test");
-        cx.assert("Test1 test2 |test3", "Test1 |test3");
+        cx.assert("Teˇst Test", "ˇst Test");
+        cx.assert("Test ˇtest", "ˇtest");
+        cx.assert("Test1 test2 ˇtest3", "Test1 ˇtest3");
         cx.assert(
             indoc! {"
                 Test test
-                |test"},
+                ˇtest"},
             indoc! {"
-                Test |
+                Test ˇ
                 test"},
         );
         cx.assert(
             indoc! {"
                 Test test
-                |
+                ˇ
                 test"},
             indoc! {"
-                Test |
+                Test ˇ
                 
                 test"},
         );
 
         let mut cx = cx.binding(["c", "shift-b"]);
-        cx.assert("Test test-test |test", "Test |test");
+        cx.assert("Test test-test ˇtest", "Test ˇtest");
     }
 
     #[gpui::test]
@@ -214,20 +214,20 @@ mod test {
         let mut cx = cx.binding(["c", "$"]).mode_after(Mode::Insert);
         cx.assert(
             indoc! {"
-                The q|uick
+                The qˇuick
                 brown fox"},
             indoc! {"
-                The q|
+                The qˇ
                 brown fox"},
         );
         cx.assert(
             indoc! {"
                 The quick
-                |
+                ˇ
                 brown fox"},
             indoc! {"
                 The quick
-                |
+                ˇ
                 brown fox"},
         );
     }
@@ -238,20 +238,20 @@ mod test {
         let mut cx = cx.binding(["c", "0"]).mode_after(Mode::Insert);
         cx.assert(
             indoc! {"
-                The q|uick
+                The qˇuick
                 brown fox"},
             indoc! {"
-                |uick
+                ˇuick
                 brown fox"},
         );
         cx.assert(
             indoc! {"
                 The quick
-                |
+                ˇ
                 brown fox"},
             indoc! {"
                 The quick
-                |
+                ˇ
                 brown fox"},
         );
     }
@@ -263,38 +263,38 @@ mod test {
         cx.assert(
             indoc! {"
                 The quick
-                brown |fox
+                brown ˇfox
                 jumps over"},
             indoc! {"
-                |
+                ˇ
                 jumps over"},
         );
         cx.assert(
             indoc! {"
                 The quick
                 brown fox
-                jumps |over"},
+                jumps ˇover"},
             indoc! {"
                 The quick
-                |"},
+                ˇ"},
         );
         cx.assert(
             indoc! {"
-                The q|uick
+                The qˇuick
                 brown fox
                 jumps over"},
             indoc! {"
-                |
+                ˇ
                 brown fox
                 jumps over"},
         );
         cx.assert(
             indoc! {"
-                |
+                ˇ
                 brown fox
                 jumps over"},
             indoc! {"
-                |
+                ˇ
                 brown fox
                 jumps over"},
         );
@@ -307,40 +307,40 @@ mod test {
         cx.assert(
             indoc! {"
                 The quick
-                brown |fox
+                brown ˇfox
                 jumps over"},
             indoc! {"
                 The quick
-                |"},
+                ˇ"},
         );
         cx.assert(
             indoc! {"
                 The quick
                 brown fox
-                jumps |over"},
+                jumps ˇover"},
             indoc! {"
                 The quick
                 brown fox
-                |"},
+                ˇ"},
         );
         cx.assert(
             indoc! {"
-                The q|uick
+                The qˇuick
                 brown fox
                 jumps over"},
             indoc! {"
-                |
+                ˇ
                 jumps over"},
         );
         cx.assert(
             indoc! {"
                 The quick
                 brown fox
-                |"},
+                ˇ"},
             indoc! {"
                 The quick
                 brown fox
-                |"},
+                ˇ"},
         );
     }
 
@@ -351,46 +351,46 @@ mod test {
         cx.assert(
             indoc! {"
                 The quick
-                brown| fox
+                brownˇ fox
                 jumps over
                 the lazy"},
             indoc! {"
                 The quick
-                |"},
+                ˇ"},
         );
         cx.assert(
             indoc! {"
                 The quick
-                brown| fox
+                brownˇ fox
                 jumps over
                 the lazy"},
             indoc! {"
                 The quick
-                |"},
+                ˇ"},
         );
         cx.assert(
             indoc! {"
                 The quick
                 brown fox
                 jumps over
-                the l|azy"},
+                the lˇazy"},
             indoc! {"
                 The quick
                 brown fox
                 jumps over
-                |"},
+                ˇ"},
         );
         cx.assert(
             indoc! {"
                 The quick
                 brown fox
                 jumps over
-                |"},
+                ˇ"},
             indoc! {"
                 The quick
                 brown fox
                 jumps over
-                |"},
+                ˇ"},
         );
     }
 
@@ -401,11 +401,11 @@ mod test {
         cx.assert(
             indoc! {"
                 The quick
-                brown| fox
+                brownˇ fox
                 jumps over
                 the lazy"},
             indoc! {"
-                |
+                ˇ
                 jumps over
                 the lazy"},
         );
@@ -414,29 +414,29 @@ mod test {
                 The quick
                 brown fox
                 jumps over
-                the l|azy"},
-            "|",
+                the lˇazy"},
+            "ˇ",
         );
         cx.assert(
             indoc! {"
-                The q|uick
+                The qˇuick
                 brown fox
                 jumps over
                 the lazy"},
             indoc! {"
-                |
+                ˇ
                 brown fox
                 jumps over
                 the lazy"},
         );
         cx.assert(
             indoc! {"
-                |
+                ˇ
                 brown fox
                 jumps over
                 the lazy"},
             indoc! {"
-                |
+                ˇ
                 brown fox
                 jumps over
                 the lazy"},

crates/vim/src/normal/delete.rs 🔗

@@ -46,16 +46,16 @@ mod test {
     async fn test_delete_h(cx: &mut gpui::TestAppContext) {
         let cx = VimTestContext::new(cx, true).await;
         let mut cx = cx.binding(["d", "h"]);
-        cx.assert("Te|st", "T|st");
-        cx.assert("T|est", "|est");
-        cx.assert("|Test", "|Test");
+        cx.assert("Teˇst", "Tˇst");
+        cx.assert("Tˇest", "ˇest");
+        cx.assert("ˇTest", "ˇTest");
         cx.assert(
             indoc! {"
                 Test
-                |test"},
+                ˇtest"},
             indoc! {"
                 Test
-                |test"},
+                ˇtest"},
         );
     }
 
@@ -63,15 +63,15 @@ mod test {
     async fn test_delete_l(cx: &mut gpui::TestAppContext) {
         let cx = VimTestContext::new(cx, true).await;
         let mut cx = cx.binding(["d", "l"]);
-        cx.assert("|Test", "|est");
-        cx.assert("Te|st", "Te|t");
-        cx.assert("Tes|t", "Te|s");
+        cx.assert("ˇTest", "ˇest");
+        cx.assert("Teˇst", "Teˇt");
+        cx.assert("Tesˇt", "Teˇs");
         cx.assert(
             indoc! {"
-                Tes|t
+                Tesˇt
                 test"},
             indoc! {"
-                Te|s
+                Teˇs
                 test"},
         );
     }
@@ -80,104 +80,104 @@ mod test {
     async fn test_delete_w(cx: &mut gpui::TestAppContext) {
         let cx = VimTestContext::new(cx, true).await;
         let mut cx = cx.binding(["d", "w"]);
-        cx.assert("Te|st", "T|e");
-        cx.assert("T|est test", "T|test");
+        cx.assert("Teˇst", "Tˇe");
+        cx.assert("Tˇest test", "Tˇtest");
         cx.assert(
             indoc! {"
-                Test te|st
+                Test teˇst
                 test"},
             indoc! {"
-                Test t|e
+                Test tˇe
                 test"},
         );
         cx.assert(
             indoc! {"
-                Test tes|t
+                Test tesˇt
                 test"},
             indoc! {"
-                Test te|s
+                Test teˇs
                 test"},
         );
         cx.assert(
             indoc! {"
                 Test test
-                |
+                ˇ
                 test"},
             indoc! {"
                 Test test
-                |
+                ˇ
                 test"},
         );
 
         let mut cx = cx.binding(["d", "shift-w"]);
-        cx.assert("Test te|st-test test", "Test te|test");
+        cx.assert("Test teˇst-test test", "Test teˇtest");
     }
 
     #[gpui::test]
     async fn test_delete_e(cx: &mut gpui::TestAppContext) {
         let cx = VimTestContext::new(cx, true).await;
         let mut cx = cx.binding(["d", "e"]);
-        cx.assert("Te|st Test", "Te| Test");
-        cx.assert("T|est test", "T| test");
+        cx.assert("Teˇst Test", "Teˇ Test");
+        cx.assert("Tˇest test", "Tˇ test");
         cx.assert(
             indoc! {"
-                Test te|st
+                Test teˇst
                 test"},
             indoc! {"
-                Test t|e
+                Test tˇe
                 test"},
         );
         cx.assert(
             indoc! {"
-                Test tes|t
+                Test tesˇt
                 test"},
-            "Test te|s",
+            "Test teˇs",
         );
         cx.assert(
             indoc! {"
                 Test test
-                |
+                ˇ
                 test"},
             indoc! {"
                 Test test
-                |
+                ˇ
                 test"},
         );
 
         let mut cx = cx.binding(["d", "shift-e"]);
-        cx.assert("Test te|st-test test", "Test te| test");
+        cx.assert("Test teˇst-test test", "Test teˇ test");
     }
 
     #[gpui::test]
     async fn test_delete_b(cx: &mut gpui::TestAppContext) {
         let cx = VimTestContext::new(cx, true).await;
         let mut cx = cx.binding(["d", "b"]);
-        cx.assert("Te|st Test", "|st Test");
-        cx.assert("Test |test", "|test");
-        cx.assert("Test1 test2 |test3", "Test1 |test3");
+        cx.assert("Teˇst Test", "ˇst Test");
+        cx.assert("Test ˇtest", "ˇtest");
+        cx.assert("Test1 test2 ˇtest3", "Test1 ˇtest3");
         cx.assert(
             indoc! {"
                 Test test
-                |test"},
+                ˇtest"},
             // Trailing whitespace after cursor
             indoc! {"
-                Test| 
+                Testˇ 
                 test"},
         );
         cx.assert(
             indoc! {"
                 Test test
-                |
+                ˇ
                 test"},
             // Trailing whitespace after cursor
             indoc! {"
-                Test| 
+                Testˇ 
                 
                 test"},
         );
 
         let mut cx = cx.binding(["d", "shift-b"]);
-        cx.assert("Test test-test |test", "Test |test");
+        cx.assert("Test test-test ˇtest", "Test ˇtest");
     }
 
     #[gpui::test]
@@ -186,20 +186,20 @@ mod test {
         let mut cx = cx.binding(["d", "$"]);
         cx.assert(
             indoc! {"
-                The q|uick
+                The qˇuick
                 brown fox"},
             indoc! {"
-                The |q
+                The ˇq
                 brown fox"},
         );
         cx.assert(
             indoc! {"
                 The quick
-                |
+                ˇ
                 brown fox"},
             indoc! {"
                 The quick
-                |
+                ˇ
                 brown fox"},
         );
     }
@@ -210,20 +210,20 @@ mod test {
         let mut cx = cx.binding(["d", "0"]);
         cx.assert(
             indoc! {"
-                The q|uick
+                The qˇuick
                 brown fox"},
             indoc! {"
-                |uick
+                ˇuick
                 brown fox"},
         );
         cx.assert(
             indoc! {"
                 The quick
-                |
+                ˇ
                 brown fox"},
             indoc! {"
                 The quick
-                |
+                ˇ
                 brown fox"},
         );
     }
@@ -235,31 +235,31 @@ mod test {
         cx.assert(
             indoc! {"
                 The quick
-                brown |fox
+                brown ˇfox
                 jumps over"},
-            "jumps |over",
+            "jumps ˇover",
         );
         cx.assert(
             indoc! {"
                 The quick
                 brown fox
-                jumps |over"},
-            "The qu|ick",
+                jumps ˇover"},
+            "The quˇick",
         );
         cx.assert(
             indoc! {"
-                The q|uick
+                The qˇuick
                 brown fox
                 jumps over"},
             indoc! {"
-                brown| fox
+                brownˇ fox
                 jumps over"},
         );
         cx.assert(
             indoc! {"
-                |brown fox
+                ˇbrown fox
                 jumps over"},
-            "|jumps over",
+            "ˇjumps over",
         );
     }
 
@@ -270,34 +270,34 @@ mod test {
         cx.assert(
             indoc! {"
                 The quick
-                brown |fox
+                brown ˇfox
                 jumps over"},
-            "The qu|ick",
+            "The quˇick",
         );
         cx.assert(
             indoc! {"
                 The quick
                 brown fox
-                jumps |over"},
+                jumps ˇover"},
             indoc! {"
                 The quick
-                brown |fox"},
+                brown ˇfox"},
         );
         cx.assert(
             indoc! {"
-                The q|uick
+                The qˇuick
                 brown fox
                 jumps over"},
-            "jumps| over",
+            "jumpsˇ over",
         );
         cx.assert(
             indoc! {"
                 The quick
                 brown fox
-                |"},
+                ˇ"},
             indoc! {"
                 The quick
-                |brown fox"},
+                ˇbrown fox"},
         );
     }
 
@@ -308,40 +308,40 @@ mod test {
         cx.assert(
             indoc! {"
                 The quick
-                brown| fox
+                brownˇ fox
                 jumps over
                 the lazy"},
-            "The q|uick",
+            "The qˇuick",
         );
         cx.assert(
             indoc! {"
                 The quick
-                brown| fox
+                brownˇ fox
                 jumps over
                 the lazy"},
-            "The q|uick",
+            "The qˇuick",
         );
         cx.assert(
             indoc! {"
                 The quick
                 brown fox
                 jumps over
-                the l|azy"},
+                the lˇazy"},
             indoc! {"
                 The quick
                 brown fox
-                jumps| over"},
+                jumpsˇ over"},
         );
         cx.assert(
             indoc! {"
                 The quick
                 brown fox
                 jumps over
-                |"},
+                ˇ"},
             indoc! {"
                 The quick
                 brown fox
-                |jumps over"},
+                ˇjumps over"},
         );
     }
 
@@ -352,11 +352,11 @@ mod test {
         cx.assert(
             indoc! {"
                 The quick
-                brown| fox
+                brownˇ fox
                 jumps over
                 the lazy"},
             indoc! {"
-                jumps| over
+                jumpsˇ over
                 the lazy"},
         );
         cx.assert(
@@ -364,28 +364,28 @@ mod test {
                 The quick
                 brown fox
                 jumps over
-                the l|azy"},
-            "|",
+                the lˇazy"},
+            "ˇ",
         );
         cx.assert(
             indoc! {"
-                The q|uick
+                The qˇuick
                 brown fox
                 jumps over
                 the lazy"},
             indoc! {"
-                brown| fox
+                brownˇ fox
                 jumps over
                 the lazy"},
         );
         cx.assert(
             indoc! {"
-                |
+                ˇ
                 brown fox
                 jumps over
                 the lazy"},
             indoc! {"
-                |brown fox
+                ˇbrown fox
                 jumps over
                 the lazy"},
         );
@@ -397,7 +397,7 @@ mod test {
         cx.set_state(
             indoc! {"
                 The quick brown
-                fox ju|mps over
+                fox juˇmps over
                 the lazy dog"},
             Mode::Normal,
         );
@@ -407,7 +407,7 @@ mod test {
         assert_eq!(cx.active_operator(), None);
         assert_eq!(cx.mode(), Mode::Normal);
         cx.assert_editor_state(indoc! {"
-            The qu|ick brown
+            The quˇick brown
             fox jumps over
             the lazy dog"});
     }
@@ -418,7 +418,7 @@ mod test {
         cx.set_state(
             indoc! {"
                 The quick brown
-                fox ju|mps over
+                fox juˇmps over
                 the lazy dog"},
             Mode::Normal,
         );

crates/vim/src/vim.rs 🔗

@@ -216,7 +216,7 @@ mod test {
     async fn test_initially_disabled(cx: &mut gpui::TestAppContext) {
         let mut cx = VimTestContext::new(cx, false).await;
         cx.simulate_keystrokes(["h", "j", "k", "l"]);
-        cx.assert_editor_state("hjkl|");
+        cx.assert_editor_state("hjklˇ");
     }
 
     #[gpui::test]
@@ -229,24 +229,24 @@ mod test {
         // Editor acts as though vim is disabled
         cx.disable_vim();
         cx.simulate_keystrokes(["h", "j", "k", "l"]);
-        cx.assert_editor_state("hjkl|");
+        cx.assert_editor_state("hjklˇ");
 
         // Selections aren't changed if editor is blurred but vim-mode is still disabled.
-        cx.set_state("[hjkl}", Mode::Normal);
-        cx.assert_editor_state("[hjkl}");
+        cx.set_state("«hjklˇ»", Mode::Normal);
+        cx.assert_editor_state("«hjklˇ»");
         cx.update_editor(|_, cx| cx.blur());
-        cx.assert_editor_state("[hjkl}");
+        cx.assert_editor_state("«hjklˇ»");
         cx.update_editor(|_, cx| cx.focus_self());
-        cx.assert_editor_state("[hjkl}");
+        cx.assert_editor_state("«hjklˇ»");
 
         // Enabling dynamically sets vim mode again and restores normal mode
         cx.enable_vim();
         assert_eq!(cx.mode(), Mode::Normal);
         cx.simulate_keystrokes(["h", "h", "h", "l"]);
         assert_eq!(cx.buffer_text(), "hjkl".to_owned());
-        cx.assert_editor_state("h|jkl");
+        cx.assert_editor_state("hˇjkl");
         cx.simulate_keystrokes(["i", "T", "e", "s", "t"]);
-        cx.assert_editor_state("hTest|jkl");
+        cx.assert_editor_state("hTestˇjkl");
 
         // Disabling and enabling resets to normal mode
         assert_eq!(cx.mode(), Mode::Insert);
@@ -262,7 +262,7 @@ mod test {
         cx.set_state(
             indoc! {"
             The quick brown
-            fox ju|mps over
+            fox juˇmps over
             the lazy dog"},
             Mode::Normal,
         );

crates/vim/src/visual.rs 🔗

@@ -284,44 +284,44 @@ mod test {
             .mode_after(Mode::Visual { line: false });
         cx.assert(
             indoc! {"
-                The |quick brown
+                The ˇquick brown
                 fox jumps over
                 the lazy dog"},
             indoc! {"
-                The [quick brown
-                fox jumps }over
+                The «quick brown
+                fox jumps ˇ»over
                 the lazy dog"},
         );
         cx.assert(
             indoc! {"
                 The quick brown
                 fox jumps over
-                the |lazy dog"},
+                the ˇlazy dog"},
             indoc! {"
                 The quick brown
                 fox jumps over
-                the [lazy }dog"},
+                the «lazy ˇ»dog"},
         );
         cx.assert(
             indoc! {"
                 The quick brown
-                fox jumps |over
+                fox jumps ˇover
                 the lazy dog"},
             indoc! {"
                 The quick brown
-                fox jumps [over
-                }the lazy dog"},
+                fox jumps «over
+                ˇ»the lazy dog"},
         );
         let mut cx = cx
             .binding(["v", "b", "k"])
             .mode_after(Mode::Visual { line: false });
         cx.assert(
             indoc! {"
-                The |quick brown
+                The ˇquick brown
                 fox jumps over
                 the lazy dog"},
             indoc! {"
-                {The q]uick brown
+                «ˇThe q»uick brown
                 fox jumps over
                 the lazy dog"},
         );
@@ -329,20 +329,20 @@ mod test {
             indoc! {"
                 The quick brown
                 fox jumps over
-                the |lazy dog"},
+                the ˇlazy dog"},
             indoc! {"
                 The quick brown
-                {fox jumps over
-                the l]azy dog"},
+                «ˇfox jumps over
+                the l»azy dog"},
         );
         cx.assert(
             indoc! {"
                 The quick brown
-                fox jumps |over
+                fox jumps ˇover
                 the lazy dog"},
             indoc! {"
-                The {quick brown
-                fox jumps o]ver
+                The «ˇquick brown
+                fox jumps o»ver
                 the lazy dog"},
         );
     }
@@ -351,51 +351,51 @@ mod test {
     async fn test_visual_delete(cx: &mut gpui::TestAppContext) {
         let cx = VimTestContext::new(cx, true).await;
         let mut cx = cx.binding(["v", "w", "x"]);
-        cx.assert("The quick |brown", "The quick| ");
+        cx.assert("The quick ˇbrown", "The quickˇ ");
         let mut cx = cx.binding(["v", "w", "j", "x"]);
         cx.assert(
             indoc! {"
-                The |quick brown
+                The ˇquick brown
                 fox jumps over
                 the lazy dog"},
             indoc! {"
-                The |ver
+                The ˇver
                 the lazy dog"},
         );
         // Test pasting code copied on delete
         cx.simulate_keystrokes(["j", "p"]);
         cx.assert_editor_state(indoc! {"
             The ver
-            the l|quick brown
+            the lˇquick brown
             fox jumps oazy dog"});
 
         cx.assert(
             indoc! {"
                 The quick brown
                 fox jumps over
-                the |lazy dog"},
+                the ˇlazy dog"},
             indoc! {"
                 The quick brown
                 fox jumps over
-                the |og"},
+                the ˇog"},
         );
         cx.assert(
             indoc! {"
                 The quick brown
-                fox jumps |over
+                fox jumps ˇover
                 the lazy dog"},
             indoc! {"
                 The quick brown
-                fox jumps |he lazy dog"},
+                fox jumps ˇhe lazy dog"},
         );
         let mut cx = cx.binding(["v", "b", "k", "x"]);
         cx.assert(
             indoc! {"
-                The |quick brown
+                The ˇquick brown
                 fox jumps over
                 the lazy dog"},
             indoc! {"
-                |uick brown
+                ˇuick brown
                 fox jumps over
                 the lazy dog"},
         );
@@ -403,18 +403,18 @@ mod test {
             indoc! {"
                 The quick brown
                 fox jumps over
-                the |lazy dog"},
+                the ˇlazy dog"},
             indoc! {"
                 The quick brown
-                |azy dog"},
+                ˇazy dog"},
         );
         cx.assert(
             indoc! {"
                 The quick brown
-                fox jumps |over
+                fox jumps ˇover
                 the lazy dog"},
             indoc! {"
-                The |ver
+                The ˇver
                 the lazy dog"},
         );
     }
@@ -425,68 +425,68 @@ mod test {
         let mut cx = cx.binding(["shift-v", "x"]);
         cx.assert(
             indoc! {"
-                The qu|ick brown
+                The quˇick brown
                 fox jumps over
                 the lazy dog"},
             indoc! {"
-                fox ju|mps over
+                fox juˇmps over
                 the lazy dog"},
         );
         // Test pasting code copied on delete
         cx.simulate_keystroke("p");
         cx.assert_editor_state(indoc! {"
             fox jumps over
-            |The quick brown
+            ˇThe quick brown
             the lazy dog"});
 
         cx.assert(
             indoc! {"
                 The quick brown
-                fox ju|mps over
+                fox juˇmps over
                 the lazy dog"},
             indoc! {"
                 The quick brown
-                the la|zy dog"},
+                the laˇzy dog"},
         );
         cx.assert(
             indoc! {"
                 The quick brown
                 fox jumps over
-                the la|zy dog"},
+                the laˇzy dog"},
             indoc! {"
                 The quick brown
-                fox ju|mps over"},
+                fox juˇmps over"},
         );
         let mut cx = cx.binding(["shift-v", "j", "x"]);
         cx.assert(
             indoc! {"
-                The qu|ick brown
+                The quˇick brown
                 fox jumps over
                 the lazy dog"},
-            "the la|zy dog",
+            "the laˇzy dog",
         );
         // Test pasting code copied on delete
         cx.simulate_keystroke("p");
         cx.assert_editor_state(indoc! {"
             the lazy dog
-            |The quick brown
+            ˇThe quick brown
             fox jumps over"});
 
         cx.assert(
             indoc! {"
                 The quick brown
-                fox ju|mps over
+                fox juˇmps over
                 the lazy dog"},
-            "The qu|ick brown",
+            "The quˇick brown",
         );
         cx.assert(
             indoc! {"
                 The quick brown
                 fox jumps over
-                the la|zy dog"},
+                the laˇzy dog"},
             indoc! {"
                 The quick brown
-                fox ju|mps over"},
+                fox juˇmps over"},
         );
     }
 
@@ -494,44 +494,44 @@ mod test {
     async fn test_visual_change(cx: &mut gpui::TestAppContext) {
         let cx = VimTestContext::new(cx, true).await;
         let mut cx = cx.binding(["v", "w", "c"]).mode_after(Mode::Insert);
-        cx.assert("The quick |brown", "The quick |");
+        cx.assert("The quick ˇbrown", "The quick ˇ");
         let mut cx = cx.binding(["v", "w", "j", "c"]).mode_after(Mode::Insert);
         cx.assert(
             indoc! {"
-                The |quick brown
+                The ˇquick brown
                 fox jumps over
                 the lazy dog"},
             indoc! {"
-                The |ver
+                The ˇver
                 the lazy dog"},
         );
         cx.assert(
             indoc! {"
                 The quick brown
                 fox jumps over
-                the |lazy dog"},
+                the ˇlazy dog"},
             indoc! {"
                 The quick brown
                 fox jumps over
-                the |og"},
+                the ˇog"},
         );
         cx.assert(
             indoc! {"
                 The quick brown
-                fox jumps |over
+                fox jumps ˇover
                 the lazy dog"},
             indoc! {"
                 The quick brown
-                fox jumps |he lazy dog"},
+                fox jumps ˇhe lazy dog"},
         );
         let mut cx = cx.binding(["v", "b", "k", "c"]).mode_after(Mode::Insert);
         cx.assert(
             indoc! {"
-                The |quick brown
+                The ˇquick brown
                 fox jumps over
                 the lazy dog"},
             indoc! {"
-                |uick brown
+                ˇuick brown
                 fox jumps over
                 the lazy dog"},
         );
@@ -539,18 +539,18 @@ mod test {
             indoc! {"
                 The quick brown
                 fox jumps over
-                the |lazy dog"},
+                the ˇlazy dog"},
             indoc! {"
                 The quick brown
-                |azy dog"},
+                ˇazy dog"},
         );
         cx.assert(
             indoc! {"
                 The quick brown
-                fox jumps |over
+                fox jumps ˇover
                 the lazy dog"},
             indoc! {"
-                The |ver
+                The ˇver
                 the lazy dog"},
         );
     }
@@ -561,11 +561,11 @@ mod test {
         let mut cx = cx.binding(["shift-v", "c"]).mode_after(Mode::Insert);
         cx.assert(
             indoc! {"
-                The qu|ick brown
+                The quˇick brown
                 fox jumps over
                 the lazy dog"},
             indoc! {"
-                |
+                ˇ
                 fox jumps over
                 the lazy dog"},
         );
@@ -574,37 +574,37 @@ mod test {
         cx.assert_editor_state(indoc! {"
             
             fox jumps over
-            |The quick brown
+            ˇThe quick brown
             the lazy dog"});
 
         cx.assert(
             indoc! {"
                 The quick brown
-                fox ju|mps over
+                fox juˇmps over
                 the lazy dog"},
             indoc! {"
                 The quick brown
-                |
+                ˇ
                 the lazy dog"},
         );
         cx.assert(
             indoc! {"
                 The quick brown
                 fox jumps over
-                the la|zy dog"},
+                the laˇzy dog"},
             indoc! {"
                 The quick brown
                 fox jumps over
-                |"},
+                ˇ"},
         );
         let mut cx = cx.binding(["shift-v", "j", "c"]).mode_after(Mode::Insert);
         cx.assert(
             indoc! {"
-                The qu|ick brown
+                The quˇick brown
                 fox jumps over
                 the lazy dog"},
             indoc! {"
-                |
+                ˇ
                 the lazy dog"},
         );
         // Test pasting code copied on delete
@@ -612,26 +612,26 @@ mod test {
         cx.assert_editor_state(indoc! {"
             
             the lazy dog
-            |The quick brown
+            ˇThe quick brown
             fox jumps over"});
         cx.assert(
             indoc! {"
                 The quick brown
-                fox ju|mps over
+                fox juˇmps over
                 the lazy dog"},
             indoc! {"
                 The quick brown
-                |"},
+                ˇ"},
         );
         cx.assert(
             indoc! {"
                 The quick brown
                 fox jumps over
-                the la|zy dog"},
+                the laˇzy dog"},
             indoc! {"
                 The quick brown
                 fox jumps over
-                |"},
+                ˇ"},
         );
     }
 
@@ -639,16 +639,16 @@ mod test {
     async fn test_visual_yank(cx: &mut gpui::TestAppContext) {
         let cx = VimTestContext::new(cx, true).await;
         let mut cx = cx.binding(["v", "w", "y"]);
-        cx.assert("The quick |brown", "The quick |brown");
+        cx.assert("The quick ˇbrown", "The quick ˇbrown");
         cx.assert_clipboard_content(Some("brown"));
         let mut cx = cx.binding(["v", "w", "j", "y"]);
         cx.assert(
             indoc! {"
-                The |quick brown
+                The ˇquick brown
                 fox jumps over
                 the lazy dog"},
             indoc! {"
-                The |quick brown
+                The ˇquick brown
                 fox jumps over
                 the lazy dog"},
         );
@@ -659,21 +659,21 @@ mod test {
             indoc! {"
                 The quick brown
                 fox jumps over
-                the |lazy dog"},
+                the ˇlazy dog"},
             indoc! {"
                 The quick brown
                 fox jumps over
-                the |lazy dog"},
+                the ˇlazy dog"},
         );
         cx.assert_clipboard_content(Some("lazy d"));
         cx.assert(
             indoc! {"
                 The quick brown
-                fox jumps |over
+                fox jumps ˇover
                 the lazy dog"},
             indoc! {"
                 The quick brown
-                fox jumps |over
+                fox jumps ˇover
                 the lazy dog"},
         );
         cx.assert_clipboard_content(Some(indoc! {"
@@ -682,11 +682,11 @@ mod test {
         let mut cx = cx.binding(["v", "b", "k", "y"]);
         cx.assert(
             indoc! {"
-                The |quick brown
+                The ˇquick brown
                 fox jumps over
                 the lazy dog"},
             indoc! {"
-                |The quick brown
+                ˇThe quick brown
                 fox jumps over
                 the lazy dog"},
         );
@@ -695,10 +695,10 @@ mod test {
             indoc! {"
                 The quick brown
                 fox jumps over
-                the |lazy dog"},
+                the ˇlazy dog"},
             indoc! {"
                 The quick brown
-                |fox jumps over
+                ˇfox jumps over
                 the lazy dog"},
         );
         cx.assert_clipboard_content(Some(indoc! {"
@@ -707,10 +707,10 @@ mod test {
         cx.assert(
             indoc! {"
                 The quick brown
-                fox jumps |over
+                fox jumps ˇover
                 the lazy dog"},
             indoc! {"
-                The |quick brown
+                The ˇquick brown
                 fox jumps over
                 the lazy dog"},
         );
@@ -725,7 +725,7 @@ mod test {
         cx.set_state(
             indoc! {"
                 The quick brown
-                fox [jump}s over
+                fox «jumpˇ»s over
                 the lazy dog"},
             Mode::Visual { line: false },
         );
@@ -733,7 +733,7 @@ mod test {
         cx.set_state(
             indoc! {"
                 The quick brown
-                fox jump|s over
+                fox jumpˇs over
                 the lazy dog"},
             Mode::Normal,
         );
@@ -741,7 +741,7 @@ mod test {
         cx.assert_state(
             indoc! {"
                 The quick brown
-                fox jumps|jumps over
+                fox jumpsˇjumps over
                 the lazy dog"},
             Mode::Normal,
         );
@@ -749,7 +749,7 @@ mod test {
         cx.set_state(
             indoc! {"
                 The quick brown
-                fox ju|mps over
+                fox juˇmps over
                 the lazy dog"},
             Mode::Visual { line: true },
         );
@@ -757,13 +757,13 @@ mod test {
         cx.assert_state(
             indoc! {"
                 The quick brown
-                the la|zy dog"},
+                the laˇzy dog"},
             Mode::Normal,
         );
         cx.set_state(
             indoc! {"
                 The quick brown
-                the [laz}y dog"},
+                the «lazˇ»y dog"},
             Mode::Visual { line: false },
         );
         cx.simulate_keystroke("p");
@@ -771,7 +771,7 @@ mod test {
             indoc! {"
                 The quick brown
                 the 
-                |fox jumps over
+                ˇfox jumps over
                  dog"},
             Mode::Normal,
         );