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
Consistent formatting of multivariable try-with-resource blocks. #1392
The current formatting of try-with-resource blocks that manage multiple variables is strange, as it results in inconsistent alignment and doesn't match how multiline parameters or code blocks are formatted.
I would say there are different expectations for how statements vs expressions are formatted, although in the case of for, there is a mixture of statements and expressions. In general, statements are aligned to all start in the same column, whereas expressions are often joined by extra symbols that prevent such alignment. While try-with-resource has the first part wrapped in parentheses, it exclusively contains expressions so it should act more like an expression block. (I would question if the formatting you used for your for loop example is optimal, but that is a separate issue.)
Activity
cushon commentedon Nov 1, 2026
The current behaviour is deliberate, the handling of
try (is consistent with other statements that have a fixed-width keyword before(, for example:thatcomputerguy0101 commentedon Nov 2, 2026
I would say there are different expectations for how statements vs expressions are formatted, although in the case of
for, there is a mixture of statements and expressions. In general, statements are aligned to all start in the same column, whereas expressions are often joined by extra symbols that prevent such alignment. While try-with-resource has the first part wrapped in parentheses, it exclusively contains expressions so it should act more like an expression block. (I would question if the formatting you used for your for loop example is optimal, but that is a separate issue.)