Skip to content

Inner block is not moved to a new line when line length is printWidth + 1 and line ends with multiple parentheses #718

Closed
@kaidohallik

Description

@kaidohallik

Prettier-Java 2.6.5

# Options (if any):
--print-width 140
--tab-width 4

Description

When length of the text in a line is exactly printWidth + 1 and text ends with multiple parentheses then inner block is not moved to a new line.

Input:

// code snippet
public class PrettierSample {

    private void singleEndingBracketInNewLine() {
        Stream.of("some string")
            .filter(s -> s.substring(1).startsWith("exactlyPrintWidthPlusOneIsThisLineCompleteWidthAndLineEndsWithMultipleParentheses12345"))
            .forEach(System.out::println);
    }
}

Output:

// code snippet
public class PrettierSample {

    private void singleEndingBracketInNewLine() {
        Stream.of("some string")
            .filter(s -> s.substring(1).startsWith("exactlyPrintWidthPlusOneIsThisLineCompleteWidthAndLineEndsWithMultipleParentheses12345")
            )
            .forEach(System.out::println);
    }
}

Expected behavior:

// code snippet
public class PrettierSample {

    private void singleEndingBracketInNewLine() {
        Stream.of("some string")
            .filter(s ->
                s.substring(1).startsWith("exactlyPrintWidthPlusOneIsThisLineCompleteWidthAndLineEndsWithMultipleParentheses12345")
            )
            .forEach(System.out::println);
    }
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions