ktfmt icon indicating copy to clipboard operation
ktfmt copied to clipboard

Long block comments (NOT KDoc) are not reformatted

Open bethcutler opened this issue 4 years ago • 2 comments

I'm not sure if this is intentional or not, but standard block comments are not reformatted, even when they exceed the length of the line.

e.g. this remains unchanged:

  /* A cow says "Moo". A sheep says "Baa". Three singing pigs say "La la la". "No no", you say, "that isn't right! The pigs say 'oink!' all day and night." */

bethcutler avatar Jun 10 '21 18:06 bethcutler

Curious - does GJF support doing this? If yes it should be easy to piggyback.

cgrushko avatar Jun 11 '21 08:06 cgrushko

This would be great to support. Right now, if you use non-block comments the formatter can create strangely formatted comments that are annoying to cleanup manually. For example, you have a long comment:

// A cow says "Moo". A sheep says "Baa". Three singing pigs say "La la la". "No no", you say, "that isn't right! The pigs say 'oink!' all day and night."

Is reformatted as,

// A cow says "Moo". A sheep says "Baa". Three singing pigs say "La la la". "No no", you say, "that
// isn't right! The pigs say 'oink!' all day and night."

But say you want to add some words to the first line:

// A cow says "Moo". A sheep says "Baa". A horse says "Neigh". Three singing pigs say "La la la". "No no", you say, "that
// isn't right! The pigs say 'oink!' all day and night."

Is reformatted as:

// A cow says "Moo". A sheep says "Baa". A horse says "Neigh". Three singing pigs say "La la la".
// "No no", you say, "that
// isn't right! The pigs say 'oink!' all day and night."

The reason I mention this is that normally in a code review when I see this I would suggest to use block comments, but since block comments are not reformatted this is not an option.

att14 avatar Sep 20 '22 17:09 att14

GJF does not support it and we (mostly) use that to format comments. Please file an issue there https://github.com/google/google-java-format

hick209 avatar Jun 05 '24 18:06 hick209