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

Comments in parenthesis code block are wrapped on a single line #581

Closed
slemouzy opened this issue May 17, 2023 · 0 comments · Fixed by #604
Closed

Comments in parenthesis code block are wrapped on a single line #581

slemouzy opened this issue May 17, 2023 · 0 comments · Fixed by #604

Comments

@slemouzy
Copy link

Prettier-Java 2.1.0

used via spotless with the following config file

{
  "tabWidth": 4,
  "printWidth": 120,
  "trailingComma": "all"
}

Input:

import java.util.List;
import java.util.stream.Collectors;

public class Test {

    public static final void main(String[] args) {
        System.out.println(
            List.of(1, 2, 3).stream().map(
                // a very long comment which explains the beatifullness of multiplication by 2
                // yes this is very important
                v -> v * 2
            ).collect(Collectors.summingInt(v -> v))
        );
    }
}

Output:

import java.util.List;
import java.util.stream.Collectors;

public class Test {

    public static final void main(String[] args) {
        System.out.println(
            List
                .of(1, 2, 3)
                .stream()
                .map(v -> v * 2 // yes this is very important // a very long comment which explains the beatifullness of multiplication by 2
                )
                .collect(Collectors.summingInt(v -> v))
        );
    }
}

Expected behavior:

public class Test {

    public static final void main(String[] args) {
        System.out.println(
            List
                .of(1, 2, 3)
                .stream()
                .map(
                    // a very long comment which explains the beatifullness of multiplication by 2
                    // yes this is very important
                    v -> v * 2
                )
                .collect(Collectors.summingInt(v -> v))
        );
    }
}

Comments inside parenthesis blocks should remain unaltered like palantir-java-format seems to do.

jtkiesel added a commit to jtkiesel/prettier-java that referenced this issue Sep 6, 2023
jtkiesel added a commit to jtkiesel/prettier-java that referenced this issue Feb 10, 2024
jtkiesel added a commit to jtkiesel/prettier-java that referenced this issue Feb 14, 2024
jtkiesel added a commit to jtkiesel/prettier-java that referenced this issue Feb 14, 2024
jtkiesel added a commit to jtkiesel/prettier-java that referenced this issue Feb 14, 2024
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

Successfully merging a pull request may close this issue.

1 participant