Repository navigation
Commit 63b5d18
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
PiperOrigin-RevId: 10246440761 parent 60656e5 commit 63b5d18
2 files changed
Lines changed: 13 additions & 10 deletions
File tree
- core/src
- main/java/com/google/googlejavaformat/java
- test/java/com/google/googlejavaformat/java
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
116 | 115 | | |
117 | | - | |
118 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
119 | 121 | | |
120 | 122 | | |
121 | 123 | | |
122 | 124 | | |
123 | | - | |
| 125 | + | |
| 126 | + | |
124 | 127 | | |
125 | 128 | | |
126 | 129 | | |
| |||
149 | 152 | | |
150 | 153 | | |
151 | 154 | | |
152 | | - | |
153 | | - | |
| 155 | + | |
| 156 | + | |
154 | 157 | | |
155 | 158 | | |
156 | 159 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1360 | 1360 | | |
1361 | 1361 | | |
1362 | 1362 | | |
1363 | | - | |
1364 | | - | |
1365 | | - | |
1366 | | - | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
1367 | 1367 | | |
1368 | 1368 | | |
1369 | 1369 | | |
| |||
0 commit comments