Skip to content

Commit aa4a0b6

Browse files
committed
Fixed jsDoc parser - no longer omits asterisks in the middle (if the line does not start with asterisk) and additional case for whitespaces being ignored
1 parent 1907064 commit aa4a0b6

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/compiler/parser.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6337,7 +6337,7 @@ namespace ts {
63376337
break;
63386338
case SyntaxKind.AsteriskToken:
63396339
const asterisk = scanner.getTokenText();
6340-
if (state === JSDocState.SawAsterisk) {
6340+
if (state === JSDocState.SawAsterisk || state === JSDocState.SavingComments) {
63416341
// If we've already seen an asterisk, then we can no longer parse a tag on this line
63426342
state = JSDocState.SavingComments;
63436343
pushComment(asterisk);
@@ -6369,6 +6369,8 @@ namespace ts {
63696369
case SyntaxKind.EndOfFileToken:
63706370
break;
63716371
default:
6372+
// anything other than whitespace or asterisk at the beginning of the line starts the comment text
6373+
state = JSDocState.SavingComments;
63726374
pushComment(scanner.getTokenText());
63736375
break;
63746376
}

tests/cases/fourslash/commentsLinePreservation.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
//// /**
109109
//// * This is firstLine
110110
//// This is second Line
111+
//// [1]: third * line
111112
//// @param param1 first Line text
112113
//// second line text
113114
//// */
@@ -145,6 +146,6 @@ verify.quickInfos({
145146
l: ["function l(param1: string): void", "This is firstLine\nThis is second Line"],
146147
9: ["(parameter) param1: string", "first Line text\nblank line that shouldnt be shown when starting this \nsecond time information about the param again"],
147148

148-
m: ["function m(param1: string): void", "This is firstLine\nThis is second Line"],
149+
m: ["function m(param1: string): void", "This is firstLine\nThis is second Line\n[1]: third * line"],
149150
10: ["(parameter) param1: string", "first Line text\nsecond line text"]
150151
});

0 commit comments

Comments
 (0)