documents: shortcodes read per DOM text node as GitHub reads them; HTML5's p closers end a p; a TOC press follows editor anchors
CI / platforms (windows-latest) (push) Failing after 9s
CI / site (push) Successful in 22s
CI / crate (push) Failing after 10m54s
CI / platforms (ubuntu-24.04) (push) Canceled after 0s

- The first `:name:`-shaped run in a text node decides for the whole node:
  blank text or a space before it turns every shortcode, else none. Filtered
  tags are text and do not split the node. Probed on GitHub's markdown API.
- `fieldset`, `menu` and the rest of HTML5's list end an open `p`.
- `CodeEditor` carries owner anchors through each edit; the document anchors
  every heading it reads, and a TOC press goes where its anchor went.

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 00:48:26 -04:00
1 parent a744316274
commit 8e5dad8177
12 files changed
+396 -138

No files matched your search

+56
View File
@@ -132,3 +132,59 @@ fn a_press_while_the_text_waits_to_be_read_finds_the_heading(cx: &mut TestAppCon
(26, 0)
);
}
/// Makes `edits` while the text waits, caret at the top.
fn edit_waiting<'a>(
text: &str,
edits: Vec<(std::ops::Range<usize>, String)>,
cx: &'a mut TestAppContext,
) -> (Entity<MarkdownDocument>, &'a mut VisualTestContext) {
let (document, cx) = open(text, MarkdownMode::Split, cx);
document.update(cx, |document, cx| {
document
.editor
.update(cx, |editor, cx| editor.edit(edits, cx));
document.set_caret(0, 0, cx);
});
frames(cx);
assert!(!document.read_with(cx, |document, cx| document.read_now(cx)));
(document, cx)
}
fn caret(document: &Entity<MarkdownDocument>, cx: &mut VisualTestContext) -> (usize, usize) {
document.read_with(cx, |document, cx| document.caret(cx))
}
#[gpui::test]
fn a_twin_written_right_at_the_heading_goes_before_it(cx: &mut TestAppContext) {
let edits = vec![(7..7, "## B\n\n".to_string())];
let (document, cx) = edit_waiting("[toc]\n\n## B\n\ntext\n", edits, cx);
press_entry(0, Modifiers::none(), cx);
assert_eq!(caret(&document, cx), (4, 0));
}
#[gpui::test]
fn adjacent_twins_keep_who_was_deleted(cx: &mut TestAppContext) {
let twins = "[toc]\n\n## B\n\n## B\n\ntext\n";
let (document, cx) = edit_waiting(twins, vec![(7..13, String::new())], cx);
press_entry(0, Modifiers::none(), cx);
assert_eq!(
caret(&document, cx),
(0, 0),
"the deleted one moves nothing"
);
press_entry(1, Modifiers::none(), cx);
assert_eq!(caret(&document, cx), (2, 0), "the kept one moved up");
}
#[gpui::test]
fn a_heading_between_two_edits_stays_found(cx: &mut TestAppContext) {
let text = "before\n\n[toc]\n\n# A\n\nafter\n";
let edits = vec![
(0..0, "start\n".to_string()),
(text.len()..text.len(), "end\n".to_string()),
];
let (document, cx) = edit_waiting(text, edits, cx);
press_entry(0, Modifiers::none(), cx);
assert_eq!(caret(&document, cx), (5, 0));
}