fix: wrong check of param completion position at comma (#205)

This commit is contained in:
Myriad-Dreamin 2024-04-20 15:26:31 +08:00 committed by GitHub
parent b52ad52760
commit c33f14e761
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 39 additions and 3 deletions

View file

@ -177,7 +177,8 @@ pub struct DynCallTarget {
pub this: Option<Value>,
}
/// The calling convention of a function.
/// The call of a function with calling convention identified.
#[derive(Debug, Clone)]
pub enum CallConvention {
/// A static function.
Static(Func),

View file

@ -7,6 +7,41 @@ input_file: crates/tinymist-query/src/fixtures/completion/func_args2.typ
[
{
"isIncomplete": false,
"items": []
"items": [
{
"kind": 6,
"label": "class",
"textEdit": {
"newText": " class: ${1:}",
"range": {
"end": {
"character": 18,
"line": 14
},
"start": {
"character": 18,
"line": 14
}
}
}
},
{
"kind": 6,
"label": "font",
"textEdit": {
"newText": " font: ${1:}",
"range": {
"end": {
"character": 18,
"line": 14
},
"start": {
"character": 18,
"line": 14
}
}
}
}
]
}
]

View file

@ -732,7 +732,7 @@ fn complete_params(ctx: &mut CompletionContext) -> bool {
// Parameters: "func(|)", "func(hi|)", "func(12,|)".
if_chain! {
if matches!(deciding.kind(), SyntaxKind::LeftParen | SyntaxKind::Comma);
if deciding.kind() != SyntaxKind::Comma || deciding.range().end < ctx.cursor;
if deciding.kind() != SyntaxKind::Comma || deciding.range().end <= ctx.cursor;
then {
if let Some(next) = deciding.next_leaf() {
ctx.from = ctx.cursor.min(next.offset());