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
{{ message }}
Repository navigation
Commit 7f98ec8
Browse filesBrowse the repository at this point in the historyBrowse files
Indent a block comment that trails { like the statements after it
A `/* ... */` comment left on the line of an opening brace is moved onto its
own line, and landed one indent deeper than the statements of the block, or
the elements of the array initializer, that followed it. A second run moved
it back, so the output was not stable. A lambda body such as
`() -> { /* c */ f(); }` and a block after `default:` had the same defect.
visitBlock and the non-empty branch of visitArrayInitializer open a plusTwo
level and then asked for another plusTwo on the break before the comment.
OpsBuilder.build puts that comment right after the token, inside the level,
so the two indents stacked. The break now gets ZERO there. An empty block
keeps plusTwo: it closes the level right after `{`, and build moves the
comment past that close, so without the indent the comment would sit at the
column of the braces.
Ported from google/google-java-format#1464 (commit ea7b0c40), which fixesgoogle/google-java-format#1260. The tests were written first: the I1260
fixture (upstream's input plus a lambda body) and
trailingCommentAfterOpenBraceIsIdempotent in GOOGLE style failed on the
first pass before the change. The I1260EmptyBlocks fixture pins the
empty-block shapes that the change leaves as they were.
Fixes#129.
0 commit comments