mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-11-25 05:22:52 +00:00
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
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:
parent
052149a509
commit
9f8501c42a
1 changed files with 18 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue