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 `space` not handling non-ascii characters (#27053)

5brian84a8d481787f
diff --git a/crates/vim/src/motion.rs b/crates/vim/src/motion.rs
index 486474c6e76..c5af8ecf2cd 100644
--- a/crates/vim/src/motion.rs
+++ b/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("πππˇππ");
+ }
}
diff --git a/crates/vim/test_data/test_space_non_ascii.json b/crates/vim/test_data/test_space_non_ascii.json
new file mode 100644
index 00000000000..9caed6cb590
--- /dev/null
+++ b/crates/vim/test_data/test_space_non_ascii.json
@@ -0,0 +1,4 @@
+{"Put":{"state":"ˇπππππ"}}
+{"Key":"3"}
+{"Key":"space"}
+{"Get":{"state":"πππˇππ","mode":"Normal"}}