documents: edits read the caret off a CRLF split
CI / platforms (windows-latest) (push) Failing after 10s
CI / site (push) Successful in 22s
CI / crate (push) Failing after 11m47s
CI / platforms (ubuntu-24.04) (push) Canceled after 0s

The editor splits lines on LF only, so End can leave the caret
between CR and LF. The edit runner and table insert now settle the
selection before the CR; the line helpers assert they never see a
split instead of guessing.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-14 15:56:17 -04:00
1 parent ce015e7b7b
commit 6b033f3eb0
5 files changed
+52 -11

No files matched your search

+30
View File
@@ -355,3 +355,33 @@ fn tidy_in_an_open_table_keeps_it_open(cx: &mut TestAppContext) {
"| A | B |\n| ---- | ---- |\n| 1 | 2 |"
);
}
const CRLF: &str = "Intro\r\nNext\r\n";
/// A code block in CRLF text after `keys`.
fn code_block_after(keys: &str, cx: &mut TestAppContext) -> String {
let (document, cx) = open(CRLF, MarkdownMode::Source, cx);
let editor = document.read_with(cx, |document, _| document.editor().clone());
let focus = editor.read_with(cx, gpui::Focusable::focus_handle);
cx.update(|window, cx| window.focus(&focus, cx));
cx.simulate_keystrokes(keys);
document.update(cx, |document, cx| {
document
.block(crate::documents::BlockCommand::CodeBlock, cx)
.expect("taken")
});
cx.run_until_parked();
text(&document, cx)
}
const FENCE_AFTER_INTRO: &str = "Intro\r\n\r\n```\r\n\r\n```\r\n\r\nNext\r\n";
#[gpui::test]
fn a_block_after_end_in_crlf_text_reads_the_line(cx: &mut TestAppContext) {
assert_eq!(code_block_after("end", cx), FENCE_AFTER_INTRO);
}
#[gpui::test]
fn a_selection_from_inside_a_crlf_reads_the_line(cx: &mut TestAppContext) {
assert_eq!(code_block_after("end shift-right", cx), FENCE_AFTER_INTRO);
}