diff --git a/crates/vim/src/motion.rs b/crates/vim/src/motion.rs index 3d3b47b810..3b5e3296ce 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 0000000000..9909638e3f --- /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"}}