Skip to content

Commit

Permalink
fix: #691 - JSDoc.getInnerText would sometimes get the wrong text if …
Browse files Browse the repository at this point in the history
…the first line content contained an asterisk.
  • Loading branch information
cancerberoSgx authored and dsherret committed Sep 1, 2019
1 parent 287158e commit 0661508
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compiler/ast/doc/JSDoc.ts
Expand Up @@ -39,7 +39,7 @@ export class JSDoc extends JSDocBase<ts.JSDoc> {

return innerTextWithStars.split(/\n/).map(line => {
const starPos = line.indexOf("*");
if (starPos === -1)
if (starPos === -1 || line.substring(0, starPos).trim() !== "")
return line;
const substringStart = line[starPos + 1] === " " ? starPos + 2 : starPos + 1;
return line.substring(substringStart);
Expand Down
5 changes: 5 additions & 0 deletions src/tests/compiler/ast/doc/jsDocTests.ts
Expand Up @@ -134,6 +134,11 @@ describe(nameof(JSDoc), () => {
it("should return the correct inner text when using slash r slash n", () => {
doTest("/**\r\n * Description\r\n * @param - Test\r\n */function identifier() {}", "Description\r\n@param - Test");
});

it("should not modify content's stars", () => {
doTest("/** Performs `counter *= 2`.*/function identifier() {}", "Performs `counter *= 2`.");
doTest("/**\nPerforms `counter *= 2`.\n*/function identifier() {}", "Performs `counter *= 2`.");
});
});

describe(nameof<JSDoc>(n => n.set), () => {
Expand Down

0 comments on commit 0661508

Please sign in to comment.