question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Undesirable autoformatting of code

See original GitHub issue

The 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
  1. 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())
            );
}
  1. ALT + SHIFT + F
Current Result

image

Expected Result

image

Additional Informations

Sample file

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

0reactions
spottedmahncommented, Feb 21, 2020

image

is: <setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="81"/>

Which produces:

image

not 100% but pretty close

thanks @snjeza!

code/settings reference

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found