Skip to content

Avoid breaking line comments on non-breaking spaces. - #1530

Merged
copybara-service[bot] merged 1 commit into
masterfrom
test_1010281496
Nov 18, 2026
Merged

copybara-service[bot] merged 1 commit into
masterfrom
test_1010281496

Conversation

@copybara-service

Copy link
Copy Markdown

Avoid breaking line comments on non-breaking spaces.

JavaCommentsHelper.wrapLineComments previously wrapped line comments on CharMatcher.whitespace() (which matches U+00A0 NO-BREAK SPACE) while LINE_COMMENT_MISSING_SPACE_PREFIX matched ASCII \s (which does not match U+00A0). Wrapping a comment at \u00a0 produced a continuation line starting with //\u00a0, and subsequent passes inserted a space (// \u00a0) and wrapped at idx = 3, inserting a new empty // line on every run.

Break line comments only on CharMatcher.breakingWhitespace(), enable Pattern.UNICODE_CHARACTER_CLASS on LINE_COMMENT_MISSING_SPACE_PREFIX, and use CharMatcher.whitespace().trimFrom(...) in indentLineComments.

Fixes #562

`JavaCommentsHelper.wrapLineComments` previously wrapped line comments on `CharMatcher.whitespace()` (which matches U+00A0 NO-BREAK SPACE) while `LINE_COMMENT_MISSING_SPACE_PREFIX` matched ASCII `\s` (which does not match U+00A0). Wrapping a comment at `\u00a0` produced a continuation line starting with `//\u00a0`, and subsequent passes inserted a space (`// \u00a0`) and wrapped at `idx = 3`, inserting a new empty `//` line on every run.

Break line comments only on `CharMatcher.breakingWhitespace()`, enable `Pattern.UNICODE_CHARACTER_CLASS` on `LINE_COMMENT_MISSING_SPACE_PREFIX`, and use `CharMatcher.whitespace().trimFrom(...)` in `indentLineComments`.

Fixes #562

PiperOrigin-RevId: 1024644076
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Running with --replace does not converge

1 participant