From 962964e7dac33c8ae274e6bc2e6bd425b5a111d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Fri, 16 Oct 2026 14:34:16 -0400 Subject: [PATCH] Documents: the field highlighter reads front matter as front matter Without the front matter construct, an open front matter block parsed as a rule and a setext heading, so its keys drew bright and bold. The highlighter now parses as the file does. Co-Authored-By: Claude Opus 5.5 (1M context) --- src/documents/document/tests/open_look.rs | 7 +++++++ src/documents/markdown.rs | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/documents/document/tests/open_look.rs b/src/documents/document/tests/open_look.rs index f283746..2a6dbe8 100644 --- a/src/documents/document/tests/open_look.rs +++ b/src/documents/document/tests/open_look.rs @@ -186,3 +186,10 @@ fn open_code_math_and_front_matter_keep_their_panel(cx: &mut TestAppContext) { let front = styled(TargetBlock::FrontMatter, cx).text; assert_eq!((front.color, front.font_family), (Some(muted), Some(mono))); } + +#[gpui::test] +fn open_front_matter_has_no_runs(cx: &mut TestAppContext) { + cx.update(crate::init_for_tests); + let runs = cx.update(|cx| markdown_highlights("---\ntitle: R75\n---", cx)); + assert!(runs.is_empty(), "{runs:?}"); +} diff --git a/src/documents/markdown.rs b/src/documents/markdown.rs index 1440e38..d28b6ee 100644 --- a/src/documents/markdown.rs +++ b/src/documents/markdown.rs @@ -83,7 +83,7 @@ pub(crate) fn walk<'a>(node: &'a mdast::Node, out: &mut Vec<&'a mdast::Node>) { /// The marks over `text`, with the syntax writing each. pub fn marks(text: &str) -> Vec<(Range, Mark)> { - let root = tree(text); + let root = file_tree(text); let mut nodes = Vec::new(); walk(&root, &mut nodes); let mut out = Vec::new();