RFR - JDK-8200434 - String::align, String::indent (code review) (original) (raw)

Ivan Gerasimov ivan.gerasimov at oracle.com
Wed Aug 29 21:48:05 UTC 2018


Hi Jim!

Why a new line is always added to the result of indent(int):

return stream.collect(Collectors.joining("\n", "", "\n"));

Because of this, a call to str.indent(0) depends on whether the string is single-line or multi-line: In the former case it is unchanged, while in the later case it gets a newline appended. Moreover, if a multi-line string already ends with a new line, then a new new-line is not appended, which seems inconsistent.

I think, it may be better to always preserve the number of existing trailing new lines.

With kind regards, Ivan

With kind regards, Ivan Gerasimov



More information about the core-libs-dev mailing list