Title: A line comment with a no-break space gains an empty // line on every run · Issue #38 · openjavaformat/open-java-format · GitHub
Open Graph Title: A line comment with a no-break space gains an empty // line on every run · Issue #38 · openjavaformat/open-java-format
X Title: A line comment with a no-break space gains an empty // line on every run · Issue #38 · openjavaformat/open-java-format
Description: What Reported upstream as google/google-java-format#562 ("Running with --replace does not converge", 2021). The reporter's comment has a no-break space (U+00A0) right after the opening quote, which is easy to miss. It reproduces here on ...
Open Graph Description: What Reported upstream as google/google-java-format#562 ("Running with --replace does not converge", 2021). The reporter's comment has a no-break space (U+00A0) right after the opening quote, which...
X Description: What Reported upstream as google/google-java-format#562 ("Running with --replace does not converge", 2021). The reporter's comment has a no-break space (U+00A0) right after the openin...
Opengraph URL: https://github.com/openjavaformat/open-java-format/issues/38
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"A line comment with a no-break space gains an empty // line on every run","articleBody":"### What\n\nReported upstream as [google/google-java-format#562](https://github.com/google/google-java-format/issues/562) (\"Running with --replace does not converge\", 2021). The reporter's comment has a no-break space (U+00A0) right after the opening quote, which is easy to miss. It reproduces here on `main`:\n\n``` java\npublic class T {\n //String testString = \"\u003cU+00A0>thisisnotaHYPERLINKandsoitshouldntbetruncated… \\\"http://…\\\"\";\n}\n```\n\nwhere the word after the no-break space is longer than the line. The first run splits the comment in front of the no-break space, and every later run adds one more empty `//` line above the second half:\n\n``` java\n // String testString = \"\n //\n //\u003cU+00A0>thisisnotaHYPERLINKandsoitshouldntbetruncated…\n```\n\nSo the file never becomes stable, and a format check fails after every `--replace`.\n\n### Why it happens\n\n`JavaCommentsHelper.wrapLineComments` looks for a break with `CharMatcher.whitespace()`, which counts U+00A0 as whitespace, so the continuation line starts with `//` and the no-break space. On the next run `LINE_COMMENT_MISSING_SPACE_PREFIX`, whose `\\s` does not match U+00A0, reads that as a comment with no space after the slashes and inserts one. The wrap then breaks at the no-break space again, the inserted space stays behind on a line of its own, and `trim()` turns that line into an empty `//`.\n\n### Fix\n\nBreak line comments only at breaking whitespace, `CharMatcher.breakingWhitespace()`, which leaves out U+00A0, U+2007 and U+202F. A no-break space is by definition not a place to break a line. Comments without a no-break space are not affected.\n\n### Done when\n\n- the comment above formats in one run the way the next run leaves it;\n- a golden covers a long line comment whose only break opportunity is a no-break space.\n","author":{"url":"https://github.com/abashev","@type":"Person","name":"abashev"},"datePublished":"2026-09-23T07:15:30Z","url":"https://github.com/openjavaformat/open-java-format/issues/38"}
| 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:f2853af5-e57d-4530-2cb5-8cc8d967011b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8082:1A0B5D:67572:8F8B5:6AFBC738 |
| html-safe-nonce | 6b21f08b3a555ec063dd6c100d9a8401168a48477d32c7baab500b46514e423e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MDgyOjFBMEI1RDo2NzU3Mjo4RjhCNTo2QUZCQzczOCIsInZpc2l0b3JfaWQiOiI2Mjc5NjExMjk4MDM2MzAzNjcyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 0d0cdbac8912e5aa6384e27331babd9e716b6fcd9acb7a066a132e642a327bc5 |
| hovercard-subject-tag | issue:5550086276 |
| 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/38/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0a14a3f8cb4bcd437238c2aac413b0dcadf9365d496f437e421de292b62d85b6/openjavaformat/open-java-format/issues/38 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0a14a3f8cb4bcd437238c2aac413b0dcadf9365d496f437e421de292b62d85b6/openjavaformat/open-java-format/issues/38 |
| og:image:alt | What Reported upstream as google/google-java-format#562 ("Running with --replace does not converge", 2021). The reporter's comment has a no-break space (U+00A0) right after the opening quote, which... |
| 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-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width