Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kaidohallik opened this issue Feb 14, 2025 · 1 comment

Comments

@kaidohallik
Copy link

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);
    }
}
@jtkiesel
Copy link
Contributor

Thank you for reporting this issue! Prettier for JavaScript/TypeScript's output of the equivalent code snippet looks exactly like your expected behavior (here), so I agree that's what the Java plugin should output as well. I'll see if I can resolve this soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants