You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's some instability around trailing if condition comments. Eg this:
if token.comments # `comments` is always an array.
d
formats like
if token.comments
# `comments` is always an array.
d
while if it has an initial indent:
if token.comments # `comments` is always an array.
d
it formats like
if (
token.comments # `comments` is always an array.
)
d
Probably should always try and print inline (like the first example source) when it fits? Moving into the body (like the first example formatted) seems wrong
The text was updated successfully, but these errors were encountered:
So the discrepancy between the two versions was due to a location data bug in the Coffeescript dependency (updated)
Now (on iss64-if-condition-comment) both format like the second example (where the condition breaks)
(but this also messed with the formatting of tests/comments/if.coffee, see branch diff - needs to get sorted out)
In order to get it to print inline, we'd need to somehow override the fact that Prettier's printTrailingComment() includes a breakParent
Slightly similar to what I ran into in #122, it seems like currently it's sort of all-or-nothing with using Prettier's comment-printing. prettier/prettier#5087 seems to be aimed at changing that
But in the meantime maybe I should look more closely at what those other plugins are doing as workarounds - sounds like they're copy-pasting some of the individual Prettier functions but segregating them eg to their own module
Also, my understanding is that in order to avoid Prettier's own comment-printing kicking in, you have to use willPrintOwnComments(), but would be nice to see if that's the pattern other plugins are using
There's some instability around trailing if condition comments. Eg this:
formats like
while if it has an initial indent:
it formats like
Probably should always try and print inline (like the first example source) when it fits? Moving into the body (like the first example formatted) seems wrong
The text was updated successfully, but these errors were encountered: