New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix merged line comments #13438
Fix merged line comments #13438
Conversation
f9c6c9d
to
329527c
Compare
src/main/comments.js
Outdated
if ( | ||
previousCommentDocType === DOC_TYPE_LINE_SUFFIX || | ||
(previousCommentDocType === DOC_TYPE_ARRAY && | ||
getDocType(previousComment.doc[0]) === DOC_TYPE_LINE_SUFFIX) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use findInDoc
? The printed doc may change in future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests should save us. findInDoc
is recursive. Seems like too much overhead.
As an alternative solution, what if we change the return type of this function to { doc, isBlock, hasLineSuffix }
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much better!
Since you already got previous comment, may a simple check here https://github.com/thorn0/prettier/blob/ed63ad5928f5ba1dd60e5e6c0fda5906584b3989/src/main/comments.js#L511 will fix #12653? |
#12653 is about leading comments too, not only trailing ones. Let's fix it separately. BTW, we're going to need a new printer method for that check because it's a JS-specific thing. |
Description
Fixes #9959
Checklist
docs/
directory).changelog_unreleased/*/XXXX.md
file followingchangelog_unreleased/TEMPLATE.md
.✨Try the playground for this PR✨