Undesirable autoformatting of code
See original GitHub issueThe following code gets “mangled” when I autoformat the code.
Environment
- Operating System: Win10 v1909 WSL 1 Ubuntu 18.04
- JDK version: openjdk version “11.0.5” 2019-10-15
- Visual Studio Code version: 1.42.1 (user setup)
- Java extension version: 0.55.1
Steps To Reproduce
- Add the following code to a class
// before auto format
// https://stackoverflow.com/a/30026710/185123
static<T> CompletableFuture<List<T>> sequence1(List<CompletableFuture<T>> com) {
return CompletableFuture.allOf(com.toArray(new CompletableFuture<?>[0]))
.thenApply(v -> com.stream()
.map(CompletableFuture::join)
.collect(Collectors.toList())
);
}
- ALT + SHIFT + F
Current Result
Expected Result
Additional Informations
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
The code formatting problem, and how to solve it - Medium
The solution to the code formatting problem is this: every programming language should have one, and only one, valid way to format code....
Read more >Formatting code a bad thing when using a VCS?
Formatting code is not a bad thing. What is bad is making major formatting changes in the same commit as code changes. When...
Read more >Inherited code: To format or not to format? [closed]
Auto-format the inherited code just once, and then proceed without auto-formatting. ... In my opinion consistent code formatting improves legibility.
Read more >VS 15.5: unwanted automatic formatting on {}
5, my js code gets automatically reformatted when I open a curly brace (after adding the closing one automatically). All possible automatic formatting...
Read more >Turn off 100% of all code auto-formatting everywhere forever ...
Turn off 100% of all code auto-formatting everywhere forever under every ... does not work at all in my case. adds unwanted whitespaces...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You can configure your own formatter. See https://stackoverflow.com/questions/4172937/how-to-indent-the-fluent-interface-pattern-correctly-with-eclipse?rq=1
is:
<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="81"/>
Which produces:
not 100% but pretty close
thanks @snjeza!
code/settings reference