de-jcup / eclipse-yaml-editor

Eclipse YAML editor
https://marketplace.eclipse.org/content/yaml-editor
Apache License 2.0
35 stars 10 forks source link

Allow formatter to keep blank lines #110

Closed toellrich closed 2 years ago

toellrich commented 2 years ago

The formatter currently always removes blank lines. It would be great if, just like with the XML editor (see attached screenshot), it would be configurable to keep blank lines.

Preferences_2022_03_17_10_25_17 .

de-jcup commented 2 years ago

The formatting/pretty printing is done by snake yaml parser.

AFAIKS when looking at https://bitbucket.org/snakeyaml/snakeyaml/wiki/Documentation snake does not provide an option to keep blank lines.

So it would be necessary to create a workaround here - like done for comments (which are always dropped by snake).

toellrich commented 2 years ago

If it's too much of a hassle, don't worry about it. It's not a big deal. I just think that the blank lines improve readability and IntelliJ keeps them which would mean that team members who use different IDEs would produce differently formatted YAML files.

de-jcup commented 2 years ago

New preference entry

With last commit you have a new preference entry (per default the "Clear all blank lines" is disabled like in IntelliJ) image

An example

Origin

image

Formatted with "Clear blank lines" disabled

image

Formatted with "Clear blank lines" enabled (old behaviour)

image

de-jcup commented 2 years ago

@toellrich : Just release 1.9.0 on eclipse marketplace - so feature is available now.