documents: a caret inside CRLF reads as its line's end
The code editor splits lines on LF only, so End and Right can leave the caret between CR and LF. line_start and line_end now read that spot as the end of its line, so insert_table keeps CRLF around a new table. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
07fee552c3
commit
ce015e7b7b
2 files changed
+26
No files matched your search
@@ -69,6 +69,24 @@ fn a_new_table_goes_after_the_caret_line(cx: &mut TestAppContext) {
|
||||
);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn a_new_table_after_end_keeps_crlf(cx: &mut TestAppContext) {
|
||||
let (document, cx) = open("Intro\r\nNext\r\n", 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("end");
|
||||
let caret = editor.read_with(cx, |editor, _| editor.primary().range().start);
|
||||
assert_eq!(caret, 6, "End lands between CR and LF");
|
||||
document.update(cx, |document, cx| {
|
||||
document.insert_table(cx).expect("inserted")
|
||||
});
|
||||
assert_eq!(
|
||||
text(&document, cx),
|
||||
"Intro\r\n\r\n| | | |\r\n| ---- | ---- | ---- |\r\n| | | |\r\n| | | |\r\n\r\nNext\r\n"
|
||||
);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn a_match_in_visual_opens_its_block_selected(cx: &mut TestAppContext) {
|
||||
let (document, cx) = open("# A\n\nfind me here\n", MarkdownMode::Visual, cx);
|
||||
|
||||
Reference in new issue
Block a user