Title: Trailing comment after `{` is over-indented on the first pass (non-idempotent) · Issue #129 · openjavaformat/open-java-format · GitHub
Open Graph Title: Trailing comment after `{` is over-indented on the first pass (non-idempotent) · Issue #129 · openjavaformat/open-java-format
X Title: Trailing comment after `{` is over-indented on the first pass (non-idempotent) · Issue #129 · openjavaformat/open-java-format
Description: Upstream: google/google-java-format#1464 Kind: bug | Priority: medium Open PR google-java-format#1464 (fixes gjf issue google-java-format#1260): for { /* comment */ stmt; } and the analogous array initializer, visitBlock / visitArrayInit...
Open Graph Description: Upstream: google/google-java-format#1464 Kind: bug | Priority: medium Open PR google-java-format#1464 (fixes gjf issue google-java-format#1260): for { /* comment */ stmt; } and the analogous array ...
X Description: Upstream: google/google-java-format#1464 Kind: bug | Priority: medium Open PR google-java-format#1464 (fixes gjf issue google-java-format#1260): for { /* comment */ stmt; } and the analogous array ...
Opengraph URL: https://github.com/openjavaformat/open-java-format/issues/129
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Trailing comment after `{` is over-indented on the first pass (non-idempotent)","articleBody":"**Upstream:** https://github.com/google/google-java-format/pull/1464 \n**Kind:** bug | **Priority:** medium\n\nOpen PR [google-java-format#1464](https://github.com/google/google-java-format/issues/1464) (fixes gjf issue [google-java-format#1260](https://github.com/google/google-java-format/issues/1260)): for `{ /* comment */ stmt; }` and the analogous\narray initializer, `visitBlock` / `visitArrayInitializer` open a `plusTwo` level and then\nemit `tokenBreakTrailingComment(\"{\", plusTwo)`, stacking a second indent. A comment broken\nout after `{` lands one indent deeper than the statements, and a second format run moves\nit back, so the formatter is not idempotent. The fix uses `ZERO` for the trailing-comment\nindent when the block/initializer is non-empty and keeps `plusTwo` for empty ones.\n\nWhy it matters to us: we have exactly the same pattern, so the bug very likely reproduces\nin both GOOGLE and PALANTIR styles. Idempotency bugs break `spotlessCheck`-style CI.\n\nAffected files in our repo:\n- open-java-format/src/main/java/com/palantir/javaformat/java/JavaInputAstVisitor.java\n - visitBlock: `builder.open(plusTwo)` then `tokenBreakTrailingComment(\"{\", plusTwo)` (around line 2151-2152)\n - visitArrayInitializer, non-empty branch (around line 541-542)\n - other `tokenBreakTrailingComment(\"{\", plusTwo)` sites (lines ~857, 1886, 2145, 2519, 3766, 3783) should be checked for the same stacking\n\nSuggested action: port. Reproduce first with the I1260 input from the PR on our formatter\n(both styles), then apply the two-line change; the logic applies cleanly, the code differs\nonly in formatting and the extra BreakBehaviour arguments on our `open` calls.\n\n---\n_Filed from an upstream-watch ticket after manual review._","author":{"url":"https://github.com/abashev","@type":"Person","name":"abashev"},"datePublished":"2026-10-16T21:06:03Z","url":"https://github.com/openjavaformat/open-java-format/issues/129"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:841afa28-2260-6b9c-44a1-9c247a3fe323 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 825A:22AECE:6095E8:8007B6:6AFBC734 |
| html-safe-nonce | 21bdb9d5016bddba5aebc3d551eb5ddb98ed8dba633d2c8f3dec59fa7205aabe |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MjVBOjIyQUVDRTo2MDk1RTg6ODAwN0I2OjZBRkJDNzM0IiwidmlzaXRvcl9pZCI6IjU4NDU2MTkyODM4NjU2MTgyMjkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3010486716648a462901482938521f36aa5eedc4b612eb17c3a0fe4e6c99b9d5 |
| hovercard-subject-tag | issue:5891191764 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/openjavaformat/open-java-format/129/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8ba99fa06eb2e96e3864f6a7403933fea6f2cc758a0d9a51f74b97891e059037/openjavaformat/open-java-format/issues/129 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8ba99fa06eb2e96e3864f6a7403933fea6f2cc758a0d9a51f74b97891e059037/openjavaformat/open-java-format/issues/129 |
| og:image:alt | Upstream: google/google-java-format#1464 Kind: bug | Priority: medium Open PR google-java-format#1464 (fixes gjf issue google-java-format#1260): for { /* comment */ stmt; } and the analogous array ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | abashev |
| hostname | github.com |
| expected-hostname | github.com |
| None | d440bda0d812801778b27bfe9f7c1ce9ff22420c73f6f95150c4fcbca311c50b |
| turbo-cache-control | no-preview |
| go-import | github.com/openjavaformat/open-java-format git https://github.com/openjavaformat/open-java-format.git |
| octolytics-dimension-user_id | 325177626 |
| octolytics-dimension-user_login | openjavaformat |
| octolytics-dimension-repository_id | 1288055459 |
| octolytics-dimension-repository_nwo | openjavaformat/open-java-format |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | true |
| octolytics-dimension-repository_parent_id | 214273098 |
| octolytics-dimension-repository_parent_nwo | palantir/palantir-java-format |
| octolytics-dimension-repository_network_root_id | 214273098 |
| octolytics-dimension-repository_network_root_nwo | palantir/palantir-java-format |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2c43021aed8695990c86c0eaaedc600bfeffec36 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width