mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-19 10:41:56 -05:00
Merge pull request #12858 from Knagis/master
Fixed missing whitespace in jsDoc comments. Fixes #12236
This commit is contained in:
@@ -6337,7 +6337,7 @@ namespace ts {
|
||||
break;
|
||||
case SyntaxKind.AsteriskToken:
|
||||
const asterisk = scanner.getTokenText();
|
||||
if (state === JSDocState.SawAsterisk) {
|
||||
if (state === JSDocState.SawAsterisk || state === JSDocState.SavingComments) {
|
||||
// If we've already seen an asterisk, then we can no longer parse a tag on this line
|
||||
state = JSDocState.SavingComments;
|
||||
pushComment(asterisk);
|
||||
@@ -6358,7 +6358,10 @@ namespace ts {
|
||||
case SyntaxKind.WhitespaceTrivia:
|
||||
// only collect whitespace if we're already saving comments or have just crossed the comment indent margin
|
||||
const whitespace = scanner.getTokenText();
|
||||
if (state === JSDocState.SavingComments || margin !== undefined && indent + whitespace.length > margin) {
|
||||
if (state === JSDocState.SavingComments) {
|
||||
comments.push(whitespace);
|
||||
}
|
||||
else if (margin !== undefined && indent + whitespace.length > margin) {
|
||||
comments.push(whitespace.slice(margin - indent - 1));
|
||||
}
|
||||
indent += whitespace.length;
|
||||
@@ -6366,6 +6369,8 @@ namespace ts {
|
||||
case SyntaxKind.EndOfFileToken:
|
||||
break;
|
||||
default:
|
||||
// anything other than whitespace or asterisk at the beginning of the line starts the comment text
|
||||
state = JSDocState.SavingComments;
|
||||
pushComment(scanner.getTokenText());
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user