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 v$% (#10051)

Conrad Irwin65f071271396
diff --git a/crates/vim/src/motion.rs b/crates/vim/src/motion.rs
index 3d3b47b810c..3b5e3296ce1 100644
--- a/crates/vim/src/motion.rs
+++ b/crates/vim/src/motion.rs
@@ -1354,6 +1354,7 @@ fn end_of_document(
fn matching(map: &DisplaySnapshot, display_point: DisplayPoint) -> DisplayPoint {
// https://github.com/vim/vim/blob/1d87e11a1ef201b26ed87585fba70182ad0c468a/runtime/doc/motion.txt#L1200
+ let display_point = map.clip_at_line_end(display_point);
let point = display_point.to_point(map);
let offset = point.to_offset(&map.buffer_snapshot);
@@ -2109,4 +2110,23 @@ mod test {
"})
.await;
}
+
+ #[gpui::test]
+ async fn test_visual_match_eol(cx: &mut gpui::TestAppContext) {
+ let mut cx = NeovimBackedTestContext::new(cx).await;
+
+ cx.set_shared_state(indoc! {"
+ fn aˇ() {
+ return
+ }
+ "})
+ .await;
+ cx.simulate_shared_keystrokes(["v", "$", "%"]).await;
+ cx.assert_shared_state(indoc! {"
+ fn a«() {
+ return
+ }ˇ»
+ "})
+ .await;
+ }
}
diff --git a/crates/vim/test_data/test_visual_match_eol.json b/crates/vim/test_data/test_visual_match_eol.json
new file mode 100644
index 00000000000..9909638e3f2
--- /dev/null
+++ b/crates/vim/test_data/test_visual_match_eol.json
@@ -0,0 +1,5 @@
+{"Put":{"state":"fn aˇ() {\n return\n}\n"}}
+{"Key":"v"}
+{"Key":"$"}
+{"Key":"%"}
+{"Get":{"state":"fn a«() {\n return\n}ˇ»\n","mode":"Visual"}}