Skip to content

Commit

Permalink
Fixed jsDoc parser - no longer omits asterisks in the middle (if the …
Browse files Browse the repository at this point in the history
…line does not start with asterisk) and additional case for whitespaces being ignored
  • Loading branch information
Knagis committed Dec 12, 2016
1 parent 1907064 commit aa4a0b6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -6369,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;
}
Expand Down
3 changes: 2 additions & 1 deletion tests/cases/fourslash/commentsLinePreservation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
//// /**
//// * This is firstLine
//// This is second Line
//// [1]: third * line
//// @param param1 first Line text
//// second line text
//// */
Expand Down Expand Up @@ -145,6 +146,6 @@ verify.quickInfos({
l: ["function l(param1: string): void", "This is firstLine\nThis is second Line"],
9: ["(parameter) param1: string", "first Line text\nblank line that shouldnt be shown when starting this \nsecond time information about the param again"],

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

0 comments on commit aa4a0b6

Please sign in to comment.