File tree Expand file tree Collapse file tree 12 files changed +344
-5
lines changed Expand file tree Collapse file tree 12 files changed +344
-5
lines changed Original file line number Diff line number Diff line change @@ -2307,13 +2307,15 @@ namespace ts {
23072307 : "linkplain" ;
23082308 const parts = [ linkPart ( `{@${ prefix } ` ) ] ;
23092309 if ( ! link . name ) {
2310- if ( link . text ) parts . push ( linkTextPart ( link . text ) ) ;
2310+ if ( link . text ) {
2311+ parts . push ( linkTextPart ( link . text ) ) ;
2312+ }
23112313 }
23122314 else {
23132315 const symbol = checker ?. getSymbolAtLocation ( link . name ) ;
23142316 const suffix = findLinkNameEnd ( link . text ) ;
23152317 const name = getTextOfNode ( link . name ) + link . text . slice ( 0 , suffix ) ;
2316- const text = link . text . slice ( suffix ) ;
2318+ const text = skipSeparatorFromLinkText ( link . text . slice ( suffix ) ) ;
23172319 const decl = symbol ?. valueDeclaration || symbol ?. declarations ?. [ 0 ] ;
23182320 if ( decl ) {
23192321 parts . push ( linkNamePart ( name , decl ) ) ;
@@ -2327,6 +2329,15 @@ namespace ts {
23272329 return parts ;
23282330 }
23292331
2332+ function skipSeparatorFromLinkText ( text : string ) {
2333+ let pos = 0 ;
2334+ if ( text . charCodeAt ( pos ++ ) === CharacterCodes . bar ) {
2335+ while ( pos < text . length && text . charCodeAt ( pos ) === CharacterCodes . space ) pos ++ ;
2336+ return text . slice ( pos ) ;
2337+ }
2338+ return text ;
2339+ }
2340+
23302341 function findLinkNameEnd ( text : string ) {
23312342 if ( text . indexOf ( "()" ) === 0 ) return 2 ;
23322343 if ( text [ 0 ] !== "<" ) return 0 ;
Original file line number Diff line number Diff line change 141141 }
142142 },
143143 {
144- "text": "| postfix text",
144+ "text": "postfix text",
145145 "kind": "linkText"
146146 },
147147 {
Original file line number Diff line number Diff line change 141141 }
142142 },
143143 {
144- "text": "| postfix text",
144+ "text": "postfix text",
145145 "kind": "linkText"
146146 },
147147 {
Original file line number Diff line number Diff line change 141141 }
142142 },
143143 {
144- "text": "| postfix text",
144+ "text": "postfix text",
145145 "kind": "linkText"
146146 },
147147 {
Original file line number Diff line number Diff line change 1+ [
2+ {
3+ "marker": {
4+ "fileName": "/tests/cases/fourslash/quickInfoLink5.ts",
5+ "position": 67,
6+ "name": ""
7+ },
8+ "quickInfo": {
9+ "kind": "const",
10+ "kindModifiers": "",
11+ "textSpan": {
12+ "start": 67,
13+ "length": 1
14+ },
15+ "displayParts": [
16+ {
17+ "text": "const",
18+ "kind": "keyword"
19+ },
20+ {
21+ "text": " ",
22+ "kind": "space"
23+ },
24+ {
25+ "text": "B",
26+ "kind": "localName"
27+ },
28+ {
29+ "text": ":",
30+ "kind": "punctuation"
31+ },
32+ {
33+ "text": " ",
34+ "kind": "space"
35+ },
36+ {
37+ "text": "456",
38+ "kind": "stringLiteral"
39+ }
40+ ],
41+ "documentation": [
42+ {
43+ "text": "See ",
44+ "kind": "text"
45+ },
46+ {
47+ "text": "{@link ",
48+ "kind": "link"
49+ },
50+ {
51+ "text": "A",
52+ "kind": "linkName",
53+ "target": {
54+ "fileName": "/tests/cases/fourslash/quickInfoLink5.ts",
55+ "textSpan": {
56+ "start": 6,
57+ "length": 7
58+ }
59+ }
60+ },
61+ {
62+ "text": "constant A",
63+ "kind": "linkText"
64+ },
65+ {
66+ "text": "}",
67+ "kind": "link"
68+ },
69+ {
70+ "text": " instead",
71+ "kind": "text"
72+ }
73+ ]
74+ }
75+ }
76+ ]
Original file line number Diff line number Diff line change 1+ [
2+ {
3+ "marker": {
4+ "fileName": "/tests/cases/fourslash/quickInfoLink6.ts",
5+ "position": 67,
6+ "name": ""
7+ },
8+ "quickInfo": {
9+ "kind": "const",
10+ "kindModifiers": "",
11+ "textSpan": {
12+ "start": 67,
13+ "length": 1
14+ },
15+ "displayParts": [
16+ {
17+ "text": "const",
18+ "kind": "keyword"
19+ },
20+ {
21+ "text": " ",
22+ "kind": "space"
23+ },
24+ {
25+ "text": "B",
26+ "kind": "localName"
27+ },
28+ {
29+ "text": ":",
30+ "kind": "punctuation"
31+ },
32+ {
33+ "text": " ",
34+ "kind": "space"
35+ },
36+ {
37+ "text": "456",
38+ "kind": "stringLiteral"
39+ }
40+ ],
41+ "documentation": [
42+ {
43+ "text": "See ",
44+ "kind": "text"
45+ },
46+ {
47+ "text": "{@link ",
48+ "kind": "link"
49+ },
50+ {
51+ "text": "A",
52+ "kind": "linkName",
53+ "target": {
54+ "fileName": "/tests/cases/fourslash/quickInfoLink6.ts",
55+ "textSpan": {
56+ "start": 6,
57+ "length": 7
58+ }
59+ }
60+ },
61+ {
62+ "text": "constant A",
63+ "kind": "linkText"
64+ },
65+ {
66+ "text": "}",
67+ "kind": "link"
68+ },
69+ {
70+ "text": " instead",
71+ "kind": "text"
72+ }
73+ ]
74+ }
75+ }
76+ ]
Original file line number Diff line number Diff line change 1+ [
2+ {
3+ "marker": {
4+ "fileName": "/tests/cases/fourslash/quickInfoLink7.ts",
5+ "position": 46,
6+ "name": ""
7+ },
8+ "quickInfo": {
9+ "kind": "const",
10+ "kindModifiers": "",
11+ "textSpan": {
12+ "start": 46,
13+ "length": 1
14+ },
15+ "displayParts": [
16+ {
17+ "text": "const",
18+ "kind": "keyword"
19+ },
20+ {
21+ "text": " ",
22+ "kind": "space"
23+ },
24+ {
25+ "text": "B",
26+ "kind": "localName"
27+ },
28+ {
29+ "text": ":",
30+ "kind": "punctuation"
31+ },
32+ {
33+ "text": " ",
34+ "kind": "space"
35+ },
36+ {
37+ "text": "456",
38+ "kind": "stringLiteral"
39+ }
40+ ],
41+ "documentation": [
42+ {
43+ "text": "See ",
44+ "kind": "text"
45+ },
46+ {
47+ "text": "{@link ",
48+ "kind": "link"
49+ },
50+ {
51+ "text": "| ",
52+ "kind": "linkText"
53+ },
54+ {
55+ "text": "}",
56+ "kind": "link"
57+ },
58+ {
59+ "text": " instead",
60+ "kind": "text"
61+ }
62+ ]
63+ }
64+ }
65+ ]
Original file line number Diff line number Diff line change 1+ [
2+ {
3+ "marker": {
4+ "fileName": "/tests/cases/fourslash/quickInfoLink8.ts",
5+ "position": 67,
6+ "name": ""
7+ },
8+ "quickInfo": {
9+ "kind": "const",
10+ "kindModifiers": "",
11+ "textSpan": {
12+ "start": 67,
13+ "length": 1
14+ },
15+ "displayParts": [
16+ {
17+ "text": "const",
18+ "kind": "keyword"
19+ },
20+ {
21+ "text": " ",
22+ "kind": "space"
23+ },
24+ {
25+ "text": "B",
26+ "kind": "localName"
27+ },
28+ {
29+ "text": ":",
30+ "kind": "punctuation"
31+ },
32+ {
33+ "text": " ",
34+ "kind": "space"
35+ },
36+ {
37+ "text": "456",
38+ "kind": "stringLiteral"
39+ }
40+ ],
41+ "documentation": [
42+ {
43+ "text": "See ",
44+ "kind": "text"
45+ },
46+ {
47+ "text": "{@link ",
48+ "kind": "link"
49+ },
50+ {
51+ "text": "A",
52+ "kind": "linkName",
53+ "target": {
54+ "fileName": "/tests/cases/fourslash/quickInfoLink8.ts",
55+ "textSpan": {
56+ "start": 6,
57+ "length": 7
58+ }
59+ }
60+ },
61+ {
62+ "text": "constant A",
63+ "kind": "linkText"
64+ },
65+ {
66+ "text": "}",
67+ "kind": "link"
68+ },
69+ {
70+ "text": " instead",
71+ "kind": "text"
72+ }
73+ ]
74+ }
75+ }
76+ ]
Original file line number Diff line number Diff line change 1+ /// <reference path="fourslash.ts" />
2+
3+ ////const A = 123;
4+ /////**
5+ //// * See {@link A| constant A } instead
6+ //// */
7+ ////const /**/B = 456;
8+
9+ verify . baselineQuickInfo ( ) ;
Original file line number Diff line number Diff line change 1+ /// <reference path="fourslash.ts" />
2+
3+ ////const A = 123;
4+ /////**
5+ //// * See {@link A |constant A } instead
6+ //// */
7+ ////const /**/B = 456;
8+
9+ verify . baselineQuickInfo ( ) ;
You can’t perform that action at this time.
0 commit comments