From c33f14e7610d363fbf6bf87349a05f0a846c9795 Mon Sep 17 00:00:00 2001 From: Myriad-Dreamin <35292584+Myriad-Dreamin@users.noreply.github.com> Date: Sat, 20 Apr 2024 15:26:31 +0800 Subject: [PATCH] fix: wrong check of param completion position at comma (#205) --- .../tinymist-query/src/analysis/linked_def.rs | 3 +- .../completion/snaps/test@func_args2.typ.snap | 37 ++++++++++++++++++- .../tinymist-query/src/upstream/complete.rs | 2 +- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/crates/tinymist-query/src/analysis/linked_def.rs b/crates/tinymist-query/src/analysis/linked_def.rs index dd5bce24..b39a34d1 100644 --- a/crates/tinymist-query/src/analysis/linked_def.rs +++ b/crates/tinymist-query/src/analysis/linked_def.rs @@ -177,7 +177,8 @@ pub struct DynCallTarget { pub this: Option, } -/// 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), diff --git a/crates/tinymist-query/src/fixtures/completion/snaps/test@func_args2.typ.snap b/crates/tinymist-query/src/fixtures/completion/snaps/test@func_args2.typ.snap index bba0279e..af20539e 100644 --- a/crates/tinymist-query/src/fixtures/completion/snaps/test@func_args2.typ.snap +++ b/crates/tinymist-query/src/fixtures/completion/snaps/test@func_args2.typ.snap @@ -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 + } + } + } + } + ] } ] diff --git a/crates/tinymist-query/src/upstream/complete.rs b/crates/tinymist-query/src/upstream/complete.rs index 77c4b925..a7087aba 100644 --- a/crates/tinymist-query/src/upstream/complete.rs +++ b/crates/tinymist-query/src/upstream/complete.rs @@ -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());