diff --git a/src/services/utilities.ts b/src/services/utilities.ts index a5e151ac7ab..4fa12900724 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -2898,7 +2898,7 @@ export function buildLinkParts(link: JSDocLink | JSDocLinkCode | JSDocLinkPlain, if (text) parts.push(linkTextPart(text)); } else { - parts.push(linkTextPart(name + (suffix || text.indexOf("://") === 0 ? "" : " ") + text)); + parts.push(linkTextPart(name + (suffix ? "" : " ") + text)); } } parts.push(linkPart("}")); @@ -2915,15 +2915,21 @@ function skipSeparatorFromLinkText(text: string) { } function findLinkNameEnd(text: string) { + let pos = text.indexOf("://"); + if (pos === 0) { + while (pos < text.length && text.charCodeAt(pos) !== CharacterCodes.bar) pos++; + return pos; + } if (text.indexOf("()") === 0) return 2; - if (text[0] !== "<") return 0; - let brackets = 0; - let i = 0; - while (i < text.length) { - if (text[i] === "<") brackets++; - if (text[i] === ">") brackets--; - i++; - if (!brackets) return i; + if (text.charAt(0) === "<") { + let brackets = 0; + let i = 0; + while (i < text.length) { + if (text[i] === "<") brackets++; + if (text[i] === ">") brackets--; + i++; + if (!brackets) return i; + } } return 0; } diff --git a/tests/baselines/reference/quickInfoForJSDocWithHttpLinks.baseline b/tests/baselines/reference/quickInfoForJSDocWithHttpLinks.baseline index 7c8ced57be8..eb45f0ed346 100644 --- a/tests/baselines/reference/quickInfoForJSDocWithHttpLinks.baseline +++ b/tests/baselines/reference/quickInfoForJSDocWithHttpLinks.baseline @@ -286,7 +286,7 @@ "kind": "link" }, { - "text": "https", + "text": "https://hva", "kind": "linkName", "target": { "fileName": "/tests/cases/fourslash/quickInfoForJSDocWithHttpLinks.js", @@ -296,10 +296,6 @@ } } }, - { - "text": "://hva", - "kind": "linkText" - }, { "text": "}", "kind": "link" @@ -358,7 +354,7 @@ "kind": "link" }, { - "text": "https", + "text": "https://hvaD", "kind": "linkName", "target": { "fileName": "/tests/cases/fourslash/quickInfoForJSDocWithHttpLinks.js", @@ -368,10 +364,6 @@ } } }, - { - "text": "://hvaD", - "kind": "linkText" - }, { "text": "}", "kind": "link" diff --git a/tests/baselines/reference/quickInfoLink10.baseline b/tests/baselines/reference/quickInfoLink10.baseline new file mode 100644 index 00000000000..05714ee3705 --- /dev/null +++ b/tests/baselines/reference/quickInfoLink10.baseline @@ -0,0 +1,81 @@ +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/quickInfoLink10.ts", + "position": 57, + "name": "" + }, + "quickInfo": { + "kind": "const", + "kindModifiers": "", + "textSpan": { + "start": 57, + "length": 1 + }, + "displayParts": [ + { + "text": "const", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "a", + "kind": "localName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "(", + "kind": "punctuation" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "=>", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "documentation": [ + { + "text": "start ", + "kind": "text" + }, + { + "text": "{@link ", + "kind": "link" + }, + { + "text": "https://vscode.dev/ end", + "kind": "linkText" + }, + { + "text": "}", + "kind": "link" + } + ] + } + } +] \ No newline at end of file diff --git a/tests/cases/fourslash/quickInfoLink10.ts b/tests/cases/fourslash/quickInfoLink10.ts new file mode 100644 index 00000000000..5f53908e942 --- /dev/null +++ b/tests/cases/fourslash/quickInfoLink10.ts @@ -0,0 +1,8 @@ +/// + +/////** +//// * start {@link https://vscode.dev/ | end} +//// */ +////const /**/a = () => 1; + +verify.baselineQuickInfo();