fix: don't match the right paren for arg completion (#1480)

* fix: don't match the right paren for arg completion

* feat: arg_range_math

* fix: fmt
This commit is contained in:
Myriad-Dreamin 2025-03-10 20:50:29 +08:00 committed by GitHub
parent 1b141868eb
commit 7b35973741
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 32 additions and 0 deletions

View file

@ -174,6 +174,16 @@ impl<'a> CompletionCursor<'a> {
let syntax_context = classify_context(leaf.clone(), Some(cursor));
let surrounding_syntax = surrounding_syntax(&leaf);
// todo: don't match here?
if matches!(syntax, Some(SyntaxClass::Callee(..)))
&& matches!(syntax_context.as_ref(), Some(
SyntaxContext::Element { container, .. } |
SyntaxContext::Arg { args: container, .. } |
SyntaxContext::Paren { container, .. }) if container.rightmost_leaf().map(|s| s.offset()) == Some(leaf.offset()))
{
return None;
}
crate::log_debug_ct!("CompletionCursor: syntax {leaf:?} -> {syntax:#?}");
crate::log_debug_ct!("CompletionCursor: context {leaf:?} -> {syntax_context:#?}");
crate::log_debug_ct!("CompletionCursor: surrounding {leaf:?} -> {surrounding_syntax:#?}");

View file

@ -0,0 +1,2 @@
/// contains: alignment
#align()/* range 0..1 */

View file

@ -0,0 +1,2 @@
/// contains: size
$norm(x)/* range 0..1 */$

View file

@ -0,0 +1,9 @@
---
source: crates/tinymist-query/src/completion.rs
description: Completion on / (32..33)
expression: "JsonRepr::new_pure(results)"
input_file: crates/tinymist-query/src/fixtures/completion/arg_range.typ
---
[
null
]

View file

@ -0,0 +1,9 @@
---
source: crates/tinymist-query/src/completion.rs
description: Completion on / (27..28)
expression: "JsonRepr::new_pure(results)"
input_file: crates/tinymist-query/src/fixtures/completion/arg_range_math.typ
---
[
null
]