Fix vim full line operations failing when no trailing newline (#24409)

Closes #24270

Release Notes:

- Fixed an issue where doing line-wise operations in vim mode on the
last line of a file with no trailing newline would not work properly
This commit is contained in:
Ben Kunkle 2025-02-06 17:57:24 -06:00 committed by GitHub
parent 73c487c222
commit 337b9e62d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 79 additions and 17 deletions

View file

@ -1545,4 +1545,40 @@ mod test {
cx.simulate_shared_keystrokes("x escape shift-o").await;
cx.shared_state().await.assert_eq("// hello\n// ˇ\n// x\n");
}
#[gpui::test]
async fn test_yank_line_with_trailing_newline(cx: &mut gpui::TestAppContext) {
let mut cx = NeovimBackedTestContext::new(cx).await;
cx.set_shared_state("heˇllo\n").await;
cx.simulate_shared_keystrokes("y y p").await;
cx.shared_state().await.assert_eq("hello\nˇhello\n");
}
#[gpui::test]
async fn test_yank_line_without_trailing_newline(cx: &mut gpui::TestAppContext) {
let mut cx = NeovimBackedTestContext::new(cx).await;
cx.set_shared_state("heˇllo").await;
cx.simulate_shared_keystrokes("y y p").await;
cx.shared_state().await.assert_eq("hello\nˇhello");
}
#[gpui::test]
async fn test_yank_multiline_without_trailing_newline(cx: &mut gpui::TestAppContext) {
let mut cx = NeovimBackedTestContext::new(cx).await;
cx.set_shared_state("heˇllo\nhello").await;
cx.simulate_shared_keystrokes("2 y y p").await;
cx.shared_state()
.await
.assert_eq("hello\nˇhello\nhello\nhello");
}
#[gpui::test]
async fn test_dd_then_paste_without_trailing_newline(cx: &mut gpui::TestAppContext) {
let mut cx = NeovimBackedTestContext::new(cx).await;
cx.set_shared_state("heˇllo").await;
cx.simulate_shared_keystrokes("d d").await;
cx.shared_state().await.assert_eq("ˇ");
cx.simulate_shared_keystrokes("p p").await;
cx.shared_state().await.assert_eq("\nhello\nˇhello");
}
}