-
Notifications
You must be signed in to change notification settings - Fork 861
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't introduce line break at beginning of <code>
#84
Comments
The same problem occurs with This is more serious because it changes how the formatted HTML API documentation looks. See attached test cases. |
Thanks for the report. Inserting a newline after Doing the same for |
This does seem to work for Part of the rationale for breaking before and after |
It doesn't seem to be consistent now. In the ClassFileVersion test case I provided, google-java-format introduced a break before one occurrence of This made the formatting of the two My personal preference is not to have the extra trailing newline in the |
Ah, I hadn't thought about the additional inconsistency. It looks like we are willing to break between We have some logic to pin But I guess it's also possible that we'd just fully commit to putting Thanks for raising all this. It does sound like we have some different preferences, but I think there's room for changes that will make things incrementally better (or at least more consistent). |
Another problem with breaking after |
If a CODE_OPEN_TAG token is followed by a LITERAL token, break before writing the CODE_OPEN_TAG token if writing it will result in us eating up the remainder of the current line. Partially fixes google#84.
Consider this file:
The Javadoc comment gets reformatted as:
Note that a line break has been introduced between
<code>
and the subsequent character, where there was no whitespace before. I think this makes the Javadoc comment harder to read.Furthermore, the space is not closed up when google-java-format runs again, even if there is an opportunity to do so. If I subsequently add a few words to the first line of the reformatted comment:
and re-run google-java-format, then the result is:
which carefully preserves the undesired line break that google-java-format added.
I should note that all versions of this look the same in the generated HTML API documentation, so my concern is to avoid unnecessarily munging the source code.
I think the best solution would be for google-java-format to not introduce whitespace immediately after a formatting tag such as
<code>
.I have attached files that reproduce the behavior described above.
linebreakcode.zip
The text was updated successfully, but these errors were encountered: