Vscode-java: Formatter merges pipelines (and everything, including documentation comments) in a single row

Created on 26 Feb 2019  路  4Comments  路  Source: redhat-developer/vscode-java

Steps To Reproduce

1.1

return extractId(req).flatMap(cmsID -> service.find(cmsID))
            .flatMap(item -> ServerResponse.ok().syncBody(item))
            .doOnError(e -> log.debug(e.getMessage()))
            .onErrorResume(this::handleError);

1.2
```

  • " spherical: true,"
  • " query: {"
  • " status: 'publish',"
  • " $or: [{endDate: {$gt: new Date()}}, {endDate: {$exists: false}}]"
  • " },"
2. Alt Shift F / cmd k, f


##### Current Result
1.1 

return extractId(req).flatMap(cmsID -> service.find(cmsID)).flatMap(item -> ServerResponse.ok().syncBody(item))
.doOnError(e -> log.debug(e.getMessage())).onErrorResume(this::handleError);

1.2

  • " spherical: true," + " query: {" + " status: 'publish',"
  • " $or: [{endDate: {$gt: new Date()}}, {endDate: {$exists: false}}]" + " },"
    ```
Expected Result

do not touch line breaks, please.
...or do not touch line breaks, when line starts with dot
(code, /** doc comments */ )

Most helpful comment

You can add //@formatter:off at the beginning of the region you don't want to be formatted, and add //@formatter:on at the end, to turn it back on.

All 4 comments

I have the same "issue".
Camel routes like this:

from(from)
  .routeId("routeID")
  .autoStartup(true)
  .convertBodyTo(String.class, "UTF-8")
  .to(destination);

After format:
from(from).routeId("routeID").autoStartup(true).convertBodyTo(String.class, "UTF-8").to(destination);

I edited the Formatter in Eclipse and export it. Tried to use to a local path or GitHub URL but no such luck.

You can add //@formatter:off at the beginning of the region you don't want to be formatted, and add //@formatter:on at the end, to turn it back on.

thanks for workaround. 2 extra lines, but should be helpful for me, will try

I have the same issue, the suggested workaround might help but in times of functional Java and Internal DSLs the VS Code auto formatter is actually hardly useful.

Please provide a solution for this. 馃檹

Was this page helpful?
0 / 5 - 0 ratings