8215493: String::indent inconsistency with blank lines
Reviewed-by: rriggs, smarks
This commit is contained in:
parent
eeca4576d2
commit
0068f1aaa2
@ -2813,8 +2813,7 @@ public final class String
|
||||
* lines are then concatenated and returned.
|
||||
* <p>
|
||||
* If {@code n > 0} then {@code n} spaces (U+0020) are inserted at the
|
||||
* beginning of each line. {@link String#isBlank() Blank lines} are
|
||||
* unaffected.
|
||||
* beginning of each line.
|
||||
* <p>
|
||||
* If {@code n < 0} then up to {@code n}
|
||||
* {@link Character#isWhitespace(int) white space characters} are removed
|
||||
@ -2849,7 +2848,7 @@ public final class String
|
||||
: lines();
|
||||
if (n > 0) {
|
||||
final String spaces = " ".repeat(n);
|
||||
stream = stream.map(s -> s.isBlank() ? s : spaces + s);
|
||||
stream = stream.map(s -> spaces + s);
|
||||
} else if (n == Integer.MIN_VALUE) {
|
||||
stream = stream.map(s -> s.stripLeading());
|
||||
} else if (n < 0) {
|
||||
|
@ -67,7 +67,7 @@ public class Indent {
|
||||
Stream<String> stream = input.lines();
|
||||
if (adjust > 0) {
|
||||
final String spaces = " ".repeat(adjust);
|
||||
stream = stream.map(s -> s.isBlank() ? s : spaces + s);
|
||||
stream = stream.map(s -> spaces + s);
|
||||
} else if (adjust < 0) {
|
||||
stream = stream.map(s -> s.substring(Math.min(-adjust, indexOfNonWhitespace(s))));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user