Fix clipping at end of line in vim mode with inlay hints (#23975)
Closes #23877 Co-Authored-By: Ben <ben@zed.dev> Co-Authored-By: Michael <michael@zed.dev> Release Notes: - vim: Fix navigating to end of line with inlay hints --------- Co-authored-by: Ben <ben@zed.dev> Co-authored-by: Michael <michael@zed.dev>
This commit is contained in:
parent
5914ccdc51
commit
cb15753694
2 changed files with 47 additions and 12 deletions
|
@ -2761,6 +2761,8 @@ mod test {
|
|||
};
|
||||
use editor::display_map::Inlay;
|
||||
use indoc::indoc;
|
||||
use language::Point;
|
||||
use multi_buffer::MultiBufferRow;
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_start_end_of_paragraph(cx: &mut gpui::TestAppContext) {
|
||||
|
@ -3428,10 +3430,10 @@ mod test {
|
|||
|
||||
cx.set_state(
|
||||
indoc! {"
|
||||
struct Foo {
|
||||
ˇ
|
||||
}
|
||||
"},
|
||||
struct Foo {
|
||||
ˇ
|
||||
}
|
||||
"},
|
||||
Mode::Normal,
|
||||
);
|
||||
|
||||
|
@ -3445,9 +3447,40 @@ mod test {
|
|||
cx.simulate_keystrokes("j");
|
||||
cx.assert_state(
|
||||
indoc! {"
|
||||
struct Foo {
|
||||
struct Foo {
|
||||
|
||||
ˇ}
|
||||
ˇ}
|
||||
"},
|
||||
Mode::Normal,
|
||||
);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_clipping_with_inlay_hints_end_of_line(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = VimTestContext::new(cx, true).await;
|
||||
|
||||
cx.set_state(
|
||||
indoc! {"
|
||||
ˇstruct Foo {
|
||||
|
||||
}
|
||||
"},
|
||||
Mode::Normal,
|
||||
);
|
||||
cx.update_editor(|editor, _window, cx| {
|
||||
let snapshot = editor.buffer().read(cx).snapshot(cx);
|
||||
let end_of_line =
|
||||
snapshot.anchor_after(Point::new(0, snapshot.line_len(MultiBufferRow(0))));
|
||||
let inlay_text = " hint";
|
||||
let inlay = Inlay::inline_completion(1, end_of_line, inlay_text);
|
||||
editor.splice_inlays(vec![], vec![inlay], cx);
|
||||
});
|
||||
cx.simulate_keystrokes("$");
|
||||
cx.assert_state(
|
||||
indoc! {"
|
||||
struct Foo ˇ{
|
||||
|
||||
}
|
||||
"},
|
||||
Mode::Normal,
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue