prettier/prettier-vscode

Inconsistency in line break formatting in Java with Prettier in VS Code

drakgoku opened this issue · 1 comments

When I format this example code with java or java spring boot.:

❌Incorrect

public interface IUserDao { // If I format like this, it leaves it like this
 List<User> getAll();

 User getById(Long id);

 User save(User user);

 User update(User user);

 void delete(Longid);

}

✅ correct

public interface IUserDao { // If I format like this, it leaves it like this

 List<User> getAll();

 User getById(Long id);

 User save(User user);

 User update(User user);

 void delete(Longid);

}

Is there a way to tell pretier to do the second way "always"?

I have tried:

 "prettier.printWidth": 80,
 "prettier.proseWrap": "always",
 "prettier.bracketSpacing": true,
 "prettier.bracketSameLine": false,
 "prettier.insertPragma": true,
 "prettier.requirePragma": true

It does not work.
Note, it also has to work for javadocs and everything.

This has worked since 2007 in eclipse. We are in 2024.
As an example of a good format:
image

Most likely done with eclipse.

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.