vim: fix v$% (#10051)

Release Notes:

- vim: Fixed `%` in visual mode when at the end of a line.
This commit is contained in:
Conrad Irwin 2024-04-01 14:18:09 -06:00 committed by GitHub
parent 8b586ef8e7
commit 65f0712713
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 0 deletions

View File

@ -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 () {
return
}
"})
.await;
cx.simulate_shared_keystrokes(["v", "$", "%"]).await;
cx.assert_shared_state(indoc! {"
fn a«() {
return
}ˇ»
"})
.await;
}
}

View File

@ -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"}}