Skip to content

Commit

Permalink
Merge branch 'main' into null_proto_obj
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlomieju committed May 22, 2024
2 parents 468663b + cbddf46 commit 26ce832
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
9 changes: 6 additions & 3 deletions cli/lsp/tsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3283,14 +3283,17 @@ impl CompletionEntryDetails {
None
};
let documentation = if let Some(parts) = &self.documentation {
// NOTE: similar as `QuickInfo::to_hover()`
let mut value = display_parts_to_string(parts, language_server);
if let Some(tags) = &self.tags {
let tag_documentation = tags
let tags_preview = tags
.iter()
.map(|tag_info| get_tag_documentation(tag_info, language_server))
.collect::<Vec<String>>()
.join("");
value = format!("{value}\n\n{tag_documentation}");
.join(" \n\n");
if !tags_preview.is_empty() {
value = format!("{value}\n\n{tags_preview}");
}
}
Some(lsp::Documentation::MarkupContent(lsp::MarkupContent {
kind: lsp::MarkupKind::Markdown,
Expand Down
26 changes: 13 additions & 13 deletions tests/integration/lsp_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6967,7 +6967,7 @@ fn lsp_completions_auto_import() {
"uri": "file:///a/🦕.ts",
"languageId": "typescript",
"version": 1,
"text": "export const foo = \"foo\";\n",
"text": "/**\n *\n * @example\n * ```ts\n * const result = add(1, 2);\n * console.log(result); // 3\n * ```\n *\n * @param {number} a - The first number\n * @param {number} b - The second number\n */\nexport function add(a: number, b: number) {\n return a + b;\n}",
}
}));
client.did_open(json!({
Expand All @@ -6984,20 +6984,20 @@ fn lsp_completions_auto_import() {
json!({ "triggerKind": 1 }),
);
assert!(!list.is_incomplete);
let item = list.items.iter().find(|item| item.label == "foo");
let item = list.items.iter().find(|item| item.label == "add");
let Some(item) = item else {
panic!("completions items missing 'foo' symbol");
panic!("completions items missing 'add' symbol");
};
let mut item_value = serde_json::to_value(item).unwrap();
item_value["data"]["tsc"]["data"]["exportMapKey"] =
serde_json::Value::String("".to_string());

let req = json!({
"label": "foo",
"label": "add",
"labelDetails": {
"description": "./🦕.ts",
},
"kind": 6,
"kind": 3,
"sortText": "￿16_0",
"commitCharacters": [
".",
Expand All @@ -7009,14 +7009,14 @@ fn lsp_completions_auto_import() {
"tsc": {
"specifier": "file:///a/file.ts",
"position": 12,
"name": "foo",
"name": "add",
"source": "./%F0%9F%A6%95.ts",
"specifierRewrite": [
"./%F0%9F%A6%95.ts",
"./🦕.ts",
],
"data": {
"exportName": "foo",
"exportName": "add",
"exportMapKey": "",
"moduleSpecifier": "./%F0%9F%A6%95.ts",
"fileName": "file:///a/%F0%9F%A6%95.ts"
Expand All @@ -7031,15 +7031,15 @@ fn lsp_completions_auto_import() {
assert_eq!(
res,
json!({
"label": "foo",
"label": "add",
"labelDetails": {
"description": "./🦕.ts",
},
"kind": 6,
"detail": "const foo: \"foo\"",
"kind": 3,
"detail": "function add(a: number, b: number): number",
"documentation": {
"kind": "markdown",
"value": ""
"value": "\n\n*@example* \n```ts\nconst result = add(1, 2);\nconsole.log(result); // 3\n``` \n\n*@param* - a - The first number \n\n*@param* - b - The second number"
},
"sortText": "￿16_0",
"additionalTextEdits": [
Expand All @@ -7048,7 +7048,7 @@ fn lsp_completions_auto_import() {
"start": { "line": 0, "character": 0 },
"end": { "line": 0, "character": 0 }
},
"newText": "import { foo } from \"./🦕.ts\";\n\n"
"newText": "import { add } from \"./🦕.ts\";\n\n"
}
]
})
Expand Down Expand Up @@ -10161,7 +10161,7 @@ fn lsp_completions_complete_function_calls() {
"detail": "(method) Array<never>.map<U>(callbackfn: (value: never, index: number, array: never[]) => U, thisArg?: any): U[]",
"documentation": {
"kind": "markdown",
"value": "Calls a defined callback function on each element of an array, and returns an array that contains the results.\n\n*@param* - callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.*@param* - thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value."
"value": "Calls a defined callback function on each element of an array, and returns an array that contains the results.\n\n*@param* - callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. \n\n*@param* - thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value."
},
"sortText": "1",
"insertText": "map(${1:callbackfn})",
Expand Down
4 changes: 2 additions & 2 deletions tests/testdata/task/npx/non_existent.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Task non-existent npx this-command-should-not-exist-for-you
npm ERR! code E404
npm ERR! 404 Not Found - GET http://localhost:4260/this-command-should-not-exist-for-you
npm [WILDCARD] code E404
npm [WILDCARD] 404 Not Found - GET http://localhost:4260/this-command-should-not-exist-for-you
[WILDCARD]

0 comments on commit 26ce832

Please sign in to comment.