Drop trailing tabs from comments instead of writing them out · openjavaformat/open-java-format@17f6a1b · GitHub
Skip to content

Commit 17f6a1b

Browse files
Eckaaaaaatabashev
authored andcommitted
Drop trailing tabs from comments instead of writing them out
A line comment that ended in tabs, "// comment\t\t\t", kept them in the output, so the formatted file had trailing whitespace where the same comment ending in spaces had none. JavaOutput collected pending spaces in a counter and wrote them only in front of the next non-blank character, which is what drops trailing spaces; a tab fell through to the default case and was written straight away. This ports google/google-java-format#423 by Alexander Eckert (upstream commit 05f57ec9, fixing google/google-java-format#422): pending whitespace is kept as text, tabs included, and written out only when something follows it on the line, so a tab inside a comment stays and a tab at the end of one goes. The removeTrailingTabsInComments test comes from upstream, in this project's style. The 15,747 files of the JDK 21 sources format exactly as before.
1 parent 746fb60 commit 17f6a1b

2 files changed

Lines changed: 24 additions & 9 deletions

File tree

‎open-java-format/src/main/java/com/palantir/javaformat/java/JavaOutput.java‎

Lines changed: 14 additions & 9 deletions

‎open-java-format/src/test/java/com/palantir/javaformat/java/FormatterTest.java‎

Lines changed: 10 additions & 0 deletions

0 commit comments

Comments
 (0)