From 14c95e1a82ae8e435db06952555662e25dee2d04 Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Sat, 28 Oct 2023 22:01:11 +0300 Subject: [PATCH] feat(55737): handle jsdoc links separated by a bar token without spaces --- src/services/utilities.ts | 3 +- .../reference/quickInfoLink11.baseline | 121 ++++++++++++++++++ tests/cases/fourslash/quickInfoLink11.ts | 13 ++ 3 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/quickInfoLink11.baseline create mode 100644 tests/cases/fourslash/quickInfoLink11.ts diff --git a/src/services/utilities.ts b/src/services/utilities.ts index b14d16bd671c2..363868e80c580 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -2977,7 +2977,8 @@ export function buildLinkParts(link: JSDocLink | JSDocLinkCode | JSDocLinkPlain, if (text) parts.push(linkTextPart(text)); } else { - parts.push(linkTextPart(name + (suffix ? "" : " ") + text)); + const separator = suffix === 0 || (link.text.charCodeAt(suffix) === CharacterCodes.bar && name.charCodeAt(name.length - 1) !== CharacterCodes.space) ? " " : ""; + parts.push(linkTextPart(name + separator + text)); } } parts.push(linkPart("}")); diff --git a/tests/baselines/reference/quickInfoLink11.baseline b/tests/baselines/reference/quickInfoLink11.baseline new file mode 100644 index 0000000000000..ae30c4edfb59b --- /dev/null +++ b/tests/baselines/reference/quickInfoLink11.baseline @@ -0,0 +1,121 @@ +// === QuickInfo === +=== /tests/cases/fourslash/quickInfoLink11.ts === +// /** +// * {@link https://vscode.dev} +// * [link text]{https://vscode.dev} +// * {@link https://vscode.dev|link text} +// * {@link https://vscode.dev link text} +// */ +// function f() {} +// +// f(); +// ^ +// | ---------------------------------------------------------------------- +// | function f(): void +// | {@link https://vscode.dev} +// | [link text]{https://vscode.dev} +// | {@link https://vscode.dev link text} +// | {@link https://vscode.dev link text} +// | ---------------------------------------------------------------------- + +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/quickInfoLink11.ts", + "position": 170, + "name": "" + }, + "item": { + "kind": "function", + "kindModifiers": "", + "textSpan": { + "start": 170, + "length": 1 + }, + "displayParts": [ + { + "text": "function", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "f", + "kind": "functionName" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "void", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "", + "kind": "text" + }, + { + "text": "{@link ", + "kind": "link" + }, + { + "text": "https://vscode.dev", + "kind": "linkText" + }, + { + "text": "}", + "kind": "link" + }, + { + "text": "\n[link text]{https://vscode.dev}\n", + "kind": "text" + }, + { + "text": "{@link ", + "kind": "link" + }, + { + "text": "https://vscode.dev link text", + "kind": "linkText" + }, + { + "text": "}", + "kind": "link" + }, + { + "text": "\n", + "kind": "text" + }, + { + "text": "{@link ", + "kind": "link" + }, + { + "text": "https://vscode.dev link text", + "kind": "linkText" + }, + { + "text": "}", + "kind": "link" + } + ] + } + } +] \ No newline at end of file diff --git a/tests/cases/fourslash/quickInfoLink11.ts b/tests/cases/fourslash/quickInfoLink11.ts new file mode 100644 index 0000000000000..da6b30659df35 --- /dev/null +++ b/tests/cases/fourslash/quickInfoLink11.ts @@ -0,0 +1,13 @@ +/// + +/////** +//// * {@link https://vscode.dev} +//// * [link text]{https://vscode.dev} +//// * {@link https://vscode.dev|link text} +//// * {@link https://vscode.dev link text} +//// */ +////function f() {} +//// +/////**/f(); + +verify.baselineQuickInfo();