google / google/google-java-format

Don't introduce line break at beginning of `<code>`

オープン
#84 コメント 6 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Java
スター
6.2k
フォーク
937
平均マージ
6分
マージ済み PR(30日)
3

説明

Consider this file:

```
public class LineBreakCode {

/**
* File with list of checkouts. Set it to /dev/null to suppress reading.
* Defaults to $HOME/.mvc-checkouts.
*/
public String checkouts = "~/.mvc-checkouts";
}
```

The Javadoc comment gets reformatted as:

```
* File with list of checkouts. Set it to /dev/null to suppress reading. Defaults to
* $HOME/.mvc-checkouts
.
```

Note that a line break has been introduced between `` 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:

```
* File with list of checkouts. You can set it to /dev/null to suppress reading. Defaults to
* $HOME/.mvc-checkouts
.
```

and re-run google-java-format, then the result is:

```
* File with list of checkouts. You can set it to /dev/null to suppress reading. Defaults to
*
* $HOME/.mvc-checkouts
.
```

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 ``.

I have attached files that reproduce the behavior described above.
[linebreakcode.zip](https://github.com/google/google-java-format/files/522523/linebreakcode.zip)

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。