Skip to content

Commit

Permalink
revert #44956 - remove hyphen separator (#48416)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-tarasyuk committed Mar 25, 2022
1 parent 3ec1b04 commit 0cc3535
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 73 deletions.
13 changes: 2 additions & 11 deletions src/services/jsDoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,23 +152,14 @@ namespace ts.JsDoc {

function getDisplayPartsFromComment(comment: string | readonly JSDocComment[], checker: TypeChecker | undefined): SymbolDisplayPart[] {
if (typeof comment === "string") {
return [textPart(skipSeparatorFromComment(comment))];
return [textPart(comment)];
}
return flatMap(
comment,
node => node.kind === SyntaxKind.JSDocText ? [textPart(skipSeparatorFromComment(node.text))] : buildLinkParts(node, checker)
node => node.kind === SyntaxKind.JSDocText ? [textPart(node.text)] : buildLinkParts(node, checker)
) as SymbolDisplayPart[];
}

function skipSeparatorFromComment(text: string) {
let pos = 0;
if (text.charCodeAt(pos++) === CharacterCodes.minus) {
while (pos < text.length && text.charCodeAt(pos) === CharacterCodes.space) pos++;
return text.slice(pos);
}
return text;
}

function getCommentDisplayParts(tag: JSDocTag, checker?: TypeChecker): SymbolDisplayPart[] | undefined {
const { comment, kind } = tag;
const namePart = getTagNameDisplayPart(kind);
Expand Down
20 changes: 10 additions & 10 deletions src/testRunner/unittests/tsserver/jsdocTag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,11 @@ x(1)`
displayPartsForJSDoc: false,
tags: [{
name: "param",
text: "y {@link C}"
text: "y - {@link C}"
}],
documentation: [{
kind: "text",
text: ""
text: "- "
}, {
kind: "link",
text: "{@link "
Expand Down Expand Up @@ -425,7 +425,7 @@ x(1)`
text: " "
}, {
kind: "text",
text: ""
text: "- "
}, {
kind: "link",
text: "{@link "
Expand Down Expand Up @@ -461,11 +461,11 @@ x(1)`
displayPartsForJSDoc: false,
tags: [{
name: "param",
text: "y {@link C}"
text: "y - {@link C}"
}],
documentation: [{
kind: "text",
text: ""
text: "- "
}, {
kind: "link",
text: "{@link "
Expand Down Expand Up @@ -496,7 +496,7 @@ x(1)`
text: " "
}, {
kind: "text",
text: ""
text: "- "
}, {
kind: "link",
text: "{@link "
Expand Down Expand Up @@ -610,7 +610,7 @@ foo`
text: " "
}, {
kind: "text",
text: "see "
text: "- see "
}, {
kind: "link",
text: "{@link "
Expand Down Expand Up @@ -641,7 +641,7 @@ foo`
displayPartsForJSDoc: false,
tags: [{
name: "param",
text: "x see {@link C}",
text: "x - see {@link C}",
}],
});
});
Expand All @@ -659,7 +659,7 @@ foo`
text: " "
}, {
kind: "text",
text: "see "
text: "- see "
}, {
kind: "link",
text: "{@link "
Expand All @@ -686,7 +686,7 @@ foo`
displayPartsForJSDoc: false,
tags: [{
name: "param",
text: "x see {@link C}",
text: "x - see {@link C}",
}],
});
});
Expand Down
64 changes: 32 additions & 32 deletions tests/baselines/reference/jsDocFunctionSignatures6.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"name": "p1",
"documentation": [
{
"text": "A string param",
"text": "- A string param",
"kind": "text"
}
],
Expand Down Expand Up @@ -81,7 +81,7 @@
"name": "p2",
"documentation": [
{
"text": "An optional param",
"text": "- An optional param",
"kind": "text"
}
],
Expand Down Expand Up @@ -110,7 +110,7 @@
"name": "p3",
"documentation": [
{
"text": "Another optional param",
"text": "- Another optional param",
"kind": "text"
}
],
Expand Down Expand Up @@ -143,7 +143,7 @@
"name": "p4",
"documentation": [
{
"text": "An optional param with a default value",
"text": "- An optional param with a default value",
"kind": "text"
}
],
Expand Down Expand Up @@ -187,7 +187,7 @@
"kind": "space"
},
{
"text": "A string param",
"text": "- A string param",
"kind": "text"
}
]
Expand All @@ -204,7 +204,7 @@
"kind": "space"
},
{
"text": "An optional param",
"text": "- An optional param",
"kind": "text"
}
]
Expand All @@ -221,7 +221,7 @@
"kind": "space"
},
{
"text": "Another optional param",
"text": "- Another optional param",
"kind": "text"
}
]
Expand All @@ -238,7 +238,7 @@
"kind": "space"
},
{
"text": "An optional param with a default value",
"text": "- An optional param with a default value",
"kind": "text"
}
]
Expand Down Expand Up @@ -308,7 +308,7 @@
"name": "p1",
"documentation": [
{
"text": "A string param",
"text": "- A string param",
"kind": "text"
}
],
Expand Down Expand Up @@ -337,7 +337,7 @@
"name": "p2",
"documentation": [
{
"text": "An optional param",
"text": "- An optional param",
"kind": "text"
}
],
Expand Down Expand Up @@ -366,7 +366,7 @@
"name": "p3",
"documentation": [
{
"text": "Another optional param",
"text": "- Another optional param",
"kind": "text"
}
],
Expand Down Expand Up @@ -399,7 +399,7 @@
"name": "p4",
"documentation": [
{
"text": "An optional param with a default value",
"text": "- An optional param with a default value",
"kind": "text"
}
],
Expand Down Expand Up @@ -443,7 +443,7 @@
"kind": "space"
},
{
"text": "A string param",
"text": "- A string param",
"kind": "text"
}
]
Expand All @@ -460,7 +460,7 @@
"kind": "space"
},
{
"text": "An optional param",
"text": "- An optional param",
"kind": "text"
}
]
Expand All @@ -477,7 +477,7 @@
"kind": "space"
},
{
"text": "Another optional param",
"text": "- Another optional param",
"kind": "text"
}
]
Expand All @@ -494,7 +494,7 @@
"kind": "space"
},
{
"text": "An optional param with a default value",
"text": "- An optional param with a default value",
"kind": "text"
}
]
Expand Down Expand Up @@ -564,7 +564,7 @@
"name": "p1",
"documentation": [
{
"text": "A string param",
"text": "- A string param",
"kind": "text"
}
],
Expand Down Expand Up @@ -593,7 +593,7 @@
"name": "p2",
"documentation": [
{
"text": "An optional param",
"text": "- An optional param",
"kind": "text"
}
],
Expand Down Expand Up @@ -622,7 +622,7 @@
"name": "p3",
"documentation": [
{
"text": "Another optional param",
"text": "- Another optional param",
"kind": "text"
}
],
Expand Down Expand Up @@ -655,7 +655,7 @@
"name": "p4",
"documentation": [
{
"text": "An optional param with a default value",
"text": "- An optional param with a default value",
"kind": "text"
}
],
Expand Down Expand Up @@ -699,7 +699,7 @@
"kind": "space"
},
{
"text": "A string param",
"text": "- A string param",
"kind": "text"
}
]
Expand All @@ -716,7 +716,7 @@
"kind": "space"
},
{
"text": "An optional param",
"text": "- An optional param",
"kind": "text"
}
]
Expand All @@ -733,7 +733,7 @@
"kind": "space"
},
{
"text": "Another optional param",
"text": "- Another optional param",
"kind": "text"
}
]
Expand All @@ -750,7 +750,7 @@
"kind": "space"
},
{
"text": "An optional param with a default value",
"text": "- An optional param with a default value",
"kind": "text"
}
]
Expand Down Expand Up @@ -820,7 +820,7 @@
"name": "p1",
"documentation": [
{
"text": "A string param",
"text": "- A string param",
"kind": "text"
}
],
Expand Down Expand Up @@ -849,7 +849,7 @@
"name": "p2",
"documentation": [
{
"text": "An optional param",
"text": "- An optional param",
"kind": "text"
}
],
Expand Down Expand Up @@ -878,7 +878,7 @@
"name": "p3",
"documentation": [
{
"text": "Another optional param",
"text": "- Another optional param",
"kind": "text"
}
],
Expand Down Expand Up @@ -911,7 +911,7 @@
"name": "p4",
"documentation": [
{
"text": "An optional param with a default value",
"text": "- An optional param with a default value",
"kind": "text"
}
],
Expand Down Expand Up @@ -955,7 +955,7 @@
"kind": "space"
},
{
"text": "A string param",
"text": "- A string param",
"kind": "text"
}
]
Expand All @@ -972,7 +972,7 @@
"kind": "space"
},
{
"text": "An optional param",
"text": "- An optional param",
"kind": "text"
}
]
Expand All @@ -989,7 +989,7 @@
"kind": "space"
},
{
"text": "Another optional param",
"text": "- Another optional param",
"kind": "text"
}
]
Expand All @@ -1006,7 +1006,7 @@
"kind": "space"
},
{
"text": "An optional param with a default value",
"text": "- An optional param with a default value",
"kind": "text"
}
]
Expand Down

0 comments on commit 0cc3535

Please sign in to comment.