fix: complete type of type having constructors (#1419)

* fix: complete type of type having constructors

* test: update snapshot

* test: update snapshot
This commit is contained in:
Myriad-Dreamin 2025-02-27 16:26:02 +08:00 committed by GitHub
parent 96cdab38f6
commit 1fe422f963
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 15 additions and 6 deletions

View file

@ -300,12 +300,21 @@ impl TypeCompletionWorker<'_, '_, '_, '_> {
"(${params}) => ${output}",
"A custom function.",
);
} else if let Ok(cons) = ty.constructor() {
let docs = docs.or(cons.docs()).unwrap_or(ty.docs());
self.base.value_completion(
Some(ty.short_name().into()),
&Value::Func(cons),
true,
Some(docs),
);
} else {
let docs = docs.unwrap_or(ty.docs());
self.base.push_completion(Completion {
kind: CompletionKind::Syntax,
label: ty.short_name().into(),
apply: Some(eco_format!("${{{ty}}}")),
detail: Some(eco_format!("A value of type {ty}.")),
detail: Some(docs.into()),
..Completion::default()
});
}

View file

@ -9,11 +9,11 @@ input_file: crates/tinymist-query/src/fixtures/pkgs/touying-utils-current-headin
"isIncomplete": false,
"items": [
{
"kind": 15,
"kind": 3,
"label": "int",
"sortText": "001",
"textEdit": {
"newText": "${1:integer}",
"newText": "int(${1:})",
"range": {
"end": {
"character": 24,

View file

@ -45,11 +45,11 @@ input_file: crates/tinymist-query/src/fixtures/pkgs/touying-utils-markup-text.ty
}
},
{
"kind": 15,
"kind": 3,
"label": "str",
"sortText": "002",
"textEdit": {
"newText": "${1:string}",
"newText": "str(${1:})",
"range": {
"end": {
"character": 19,

View file

@ -385,7 +385,7 @@ fn e2e() {
});
let hash = replay_log(&tinymist_binary, &root.join("vscode"));
insta::assert_snapshot!(hash, @"siphash128_13:f3c3792e0e3a79652689fa02e0c33515");
insta::assert_snapshot!(hash, @"siphash128_13:e5477864b705e9810077be3560c3049b");
}
}