summaryrefslogtreecommitdiff
path: root/crates/typst-ide/src/complete.rs
diff options
context:
space:
mode:
authorcAttte <26514199+cAttte@users.noreply.github.com>2025-06-09 11:16:47 -0300
committerGitHub <noreply@github.com>2025-06-09 14:16:47 +0000
commitdf4c08f852ba3342e69caa721067804a7152e166 (patch)
treecaa136c71ebca94c02d631b8b8e3f85732a45da6 /crates/typst-ide/src/complete.rs
parent832fab58b31a16d049418bdbfe98b0352758579f (diff)
Autocomplete fixes for math mode (#6415)
Diffstat (limited to 'crates/typst-ide/src/complete.rs')
-rw-r--r--crates/typst-ide/src/complete.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/crates/typst-ide/src/complete.rs b/crates/typst-ide/src/complete.rs
index 4a36045a..a042b164 100644
--- a/crates/typst-ide/src/complete.rs
+++ b/crates/typst-ide/src/complete.rs
@@ -298,13 +298,20 @@ fn complete_math(ctx: &mut CompletionContext) -> bool {
return false;
}
- // Start of an interpolated identifier: "#|".
+ // Start of an interpolated identifier: "$#|$".
if ctx.leaf.kind() == SyntaxKind::Hash {
ctx.from = ctx.cursor;
code_completions(ctx, true);
return true;
}
+ // Behind existing interpolated identifier: "$#pa|$".
+ if ctx.leaf.kind() == SyntaxKind::Ident {
+ ctx.from = ctx.leaf.offset();
+ code_completions(ctx, true);
+ return true;
+ }
+
// Behind existing atom or identifier: "$a|$" or "$abc|$".
if matches!(
ctx.leaf.kind(),
@@ -1666,6 +1673,13 @@ mod tests {
test("#{() .a}", -2).must_include(["at", "any", "all"]);
}
+ /// Test that autocomplete in math uses the correct global scope.
+ #[test]
+ fn test_autocomplete_math_scope() {
+ test("$#col$", -2).must_include(["colbreak"]).must_exclude(["colon"]);
+ test("$col$", -2).must_include(["colon"]).must_exclude(["colbreak"]);
+ }
+
/// Test that the `before_window` doesn't slice into invalid byte
/// boundaries.
#[test]