diff options
| author | Laurenz <laurmaedje@gmail.com> | 2025-02-11 11:30:30 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-11 10:30:30 +0000 |
| commit | a0cd89b478437e53ece754a901ccfc035b4f2acf (patch) | |
| tree | 956feb0c8ddd08607fc39fc2d61d1340e3f0181e /crates/typst-ide/src/complete.rs | |
| parent | 81021fa1a277b04e8726d82fdf8f5fe11aeacab6 (diff) | |
Fix autocomplete and jumps in math (#5849)
Diffstat (limited to 'crates/typst-ide/src/complete.rs')
| -rw-r--r-- | crates/typst-ide/src/complete.rs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/crates/typst-ide/src/complete.rs b/crates/typst-ide/src/complete.rs index 7df788dc..564b97bd 100644 --- a/crates/typst-ide/src/complete.rs +++ b/crates/typst-ide/src/complete.rs @@ -306,7 +306,10 @@ fn complete_math(ctx: &mut CompletionContext) -> bool { } // Behind existing atom or identifier: "$a|$" or "$abc|$". - if matches!(ctx.leaf.kind(), SyntaxKind::Text | SyntaxKind::MathIdent) { + if matches!( + ctx.leaf.kind(), + SyntaxKind::Text | SyntaxKind::MathText | SyntaxKind::MathIdent + ) { ctx.from = ctx.leaf.offset(); math_completions(ctx); return true; @@ -358,7 +361,7 @@ fn complete_field_accesses(ctx: &mut CompletionContext) -> bool { // Behind an expression plus dot: "emoji.|". if_chain! { if ctx.leaf.kind() == SyntaxKind::Dot - || (ctx.leaf.kind() == SyntaxKind::Text + || (matches!(ctx.leaf.kind(), SyntaxKind::Text | SyntaxKind::MathText) && ctx.leaf.text() == "."); if ctx.leaf.range().end == ctx.cursor; if let Some(prev) = ctx.leaf.prev_sibling(); @@ -1768,4 +1771,14 @@ mod tests { test("#show outline.entry: it => it.\n#outline()\n= Hi", 30) .must_include(["indented", "body", "page"]); } + + #[test] + fn test_autocomplete_symbol_variants() { + test("#sym.arrow.", -1) + .must_include(["r", "dashed"]) + .must_exclude(["cases"]); + test("$ arrow. $", -3) + .must_include(["r", "dashed"]) + .must_exclude(["cases"]); + } } |
