fix: specially identify text that is starts with @ (#2233)
Some checks are pending
tinymist::auto_tag / auto-tag (push) Waiting to run
tinymist::ci / Duplicate Actions Detection (push) Waiting to run
tinymist::ci / Check Clippy, Formatting, Completion, Documentation, and Tests (Linux) (push) Waiting to run
tinymist::ci / Check Minimum Rust version and Tests (Windows) (push) Waiting to run
tinymist::ci / prepare-build (push) Waiting to run
tinymist::ci / announce (push) Blocked by required conditions
tinymist::ci / build (push) Blocked by required conditions
tinymist::gh_pages / build-gh-pages (push) Waiting to run

Since typst v0.14, a single `@` are not longer parsed as reference
syntax, because empty reference are not allowed since typst v0.14.
However, the IDE should still handle case where user inputs a single
`@`.
This commit is contained in:
Myriad-Dreamin 2025-11-09 02:20:10 +08:00 committed by GitHub
parent 052149a509
commit 9f8501c42a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -843,6 +843,16 @@ pub fn classify_syntax(node: LinkedNode<'_>, cursor: usize) -> Option<SyntaxClas
return Some(ref_syntax);
}
if node.kind() == SyntaxKind::Text
&& node.offset() + 1 == cursor
&& node.text().starts_with('@')
{
return Some(SyntaxClass::Ref {
node,
suffix_colon: false,
});
}
// todo: check if we can remove Text here
if matches!(node.kind(), SyntaxKind::Text | SyntaxKind::MathText) {
let mode = interpret_mode_at(Some(&node));
@ -1633,6 +1643,14 @@ Text
#[test]
fn ref_syntax() {
assert_snapshot!(map_syntax("@"), @r"
@
r
");
assert_snapshot!(map_syntax("@;"), @r"
@;
r
");
assert_snapshot!(map_syntax("@ab"), @r###"
@ab
rrr