From aa4a0b64698c7e00e8ac801c8cf48decac3478ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C4=81rlis=20Ga=C5=86=C4=A3is?= Date: Tue, 13 Dec 2016 00:05:16 +0200 Subject: [PATCH] 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 --- src/compiler/parser.ts | 4 +++- tests/cases/fourslash/commentsLinePreservation.ts | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 0fae515d837a0..2f0d6a4d9754e 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -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); @@ -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; } diff --git a/tests/cases/fourslash/commentsLinePreservation.ts b/tests/cases/fourslash/commentsLinePreservation.ts index 78c863611621b..3f60bdbf43b0e 100644 --- a/tests/cases/fourslash/commentsLinePreservation.ts +++ b/tests/cases/fourslash/commentsLinePreservation.ts @@ -108,6 +108,7 @@ //// /** //// * This is firstLine //// This is second Line +//// [1]: third * line //// @param param1 first Line text //// second line text //// */ @@ -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"] });