vim: Fix `space` not handling non-ascii characters (#27053)

5brian created

Closes #26806

Changes: Clips the new point with `Bias::Right` like in
`saturating_right`

Release Notes:

- vim: Fixed `space` not handling non-ascii characters

Change summary

crates/vim/src/motion.rs                       | 10 ++++++++++
crates/vim/test_data/test_space_non_ascii.json |  4 ++++
2 files changed, 14 insertions(+)

Detailed changes

crates/vim/src/motion.rs ๐Ÿ”—

@@ -1322,6 +1322,7 @@ fn wrapping_right_single(map: &DisplaySnapshot, mut point: DisplayPoint) -> Disp
     let max_column = map.line_len(point.row()).saturating_sub(1);
     if point.column() < max_column {
         *point.column_mut() += 1;
+        point = map.clip_point(point, Bias::Right);
     } else if point.row() < map.max_point().row() {
         *point.row_mut() += 1;
         *point.column_mut() = 0;
@@ -3598,4 +3599,13 @@ mod test {
             fox jumps over
             the lห‡ยปazy dog"});
     }
+
+    #[gpui::test]
+    async fn test_space_non_ascii(cx: &mut gpui::TestAppContext) {
+        let mut cx = NeovimBackedTestContext::new(cx).await;
+
+        cx.set_shared_state("ห‡ฯ€ฯ€ฯ€ฯ€ฯ€").await;
+        cx.simulate_shared_keystrokes("3 space").await;
+        cx.shared_state().await.assert_eq("ฯ€ฯ€ฯ€ห‡ฯ€ฯ€");
+    }
 }