@@ -2161,6 +2161,9 @@ namespace Parser {
21612161 return nextTokenWithoutCheck();
21622162 }
21632163
2164+ function nextTokenJSDocInitialIndent(): JSDocSyntaxKind {
2165+ return currentToken = scanner.scanJSDocInitialIndent();
2166+ }
21642167 function nextTokenJSDoc(): JSDocSyntaxKind {
21652168 return currentToken = scanner.scanJsDocToken();
21662169 }
@@ -8641,7 +8644,7 @@ namespace Parser {
86418644 comments.push(scanner.getTokenText());
86428645 }
86438646 else if (margin !== undefined && indent + whitespaceLength > margin) {
8644- comments.push(scanner.getTokenText ().slice(margin - indent));
8647+ comments.push(scanner.getText ().slice(scanner.getTokenPos() + margin - indent, scanner.getTextPos() ));
86458648 }
86468649 indent += whitespaceLength;
86478650 break;
@@ -8671,7 +8674,12 @@ namespace Parser {
86718674 pushComment(scanner.getTokenText());
86728675 break;
86738676 }
8674- nextTokenJSDoc();
8677+ if (state === JSDocState.BeginningOfLine) {
8678+ nextTokenJSDocInitialIndent();
8679+ }
8680+ else {
8681+ nextTokenJSDoc();
8682+ }
86758683 }
86768684 removeTrailingWhitespace(comments);
86778685 if (parts.length && comments.length) {
@@ -8891,7 +8899,7 @@ namespace Parser {
88918899 const whitespaceLength = scanner.getTextPos() - scanner.getTokenPos();
88928900 // if the whitespace crosses the margin, take only the whitespace that passes the margin
88938901 if (margin !== undefined && indent + whitespaceLength > margin) {
8894- comments.push(scanner.getTokenText ().slice(margin - indent));
8902+ comments.push(scanner.getText ().slice(scanner.getTokenPos() + margin - indent, scanner.getTextPos() ));
88958903 }
88968904 indent += whitespaceLength;
88978905 }
@@ -8937,7 +8945,12 @@ namespace Parser {
89378945 break;
89388946 }
89398947 previousWhitespace = token() === SyntaxKind.WhitespaceTrivia;
8940- tok = nextTokenJSDoc();
8948+ if (state === JSDocState.BeginningOfLine) {
8949+ tok = nextTokenJSDocInitialIndent();
8950+ }
8951+ else {
8952+ tok = nextTokenJSDoc();
8953+ }
89418954 }
89428955
89438956 removeLeadingNewlines(comments);
0 commit comments