Repository navigation
Fix some bad jsdoc comment indent - #30838
Conversation
Solves the initial problem but breaks commentCommentParsing. I also found a couple more interesting cases.
I may try do a little more; `margin += tag.end - tag.pos` bothers me a bit.
|
I added a few reviewers who might have parsed things in the past. |
Nathan Shively-Sanders (sandersn)
left a comment
There was a problem hiding this comment.
Some explanatory comments
| // for malformed examples like `/** @param {string} x @returns {number} the length */` | ||
| state = JSDocState.BeginningOfLine; | ||
| margin = undefined; | ||
| indent++; |
There was a problem hiding this comment.
this was just wrong, as far as I can tell, but only was used for tags followed by a newline:
@ex
stuffThere was a problem hiding this comment.
That is, all our previous tests cases looked like this:
@param x comment
comment
indentNever like this:
@example
comment
comment
indentso this erroneous increment was hidden by the fact that indent had already passed margin.
| } | ||
|
|
||
| function parseTag(indent: number) { | ||
| function parseTag(margin: number) { |
There was a problem hiding this comment.
margin is the thing that's fixed, whereas indent goes up for each line. So this name was wrong before.
| const whitespace = scanner.getTokenText(); | ||
| // if the whitespace crosses the margin, take only the whitespace that passes the margin | ||
| if (margin !== undefined && indent + whitespace.length > margin) { | ||
| comments.push(whitespace.slice(margin - indent - 1)); |
There was a problem hiding this comment.
this math was also wrong before, for the same reason as the indent++
Andrew Branch (andrewbranch)
left a comment
There was a problem hiding this comment.
Makes sense to me 👍🏽
Fixes #15749 plus a few other cases I discovered.
Yes, I know the baseline format is horrible. Sorry.