vscode-java icon indicating copy to clipboard operation
vscode-java copied to clipboard

Formatting not working correctly.

Open AMetnik opened this issue 3 years ago • 9 comments

The java-formatter.xml 'org.eclipse.jdt.core.formatter.lineSplit' value 0 is not respected. Value 0 Should disable line-combining/breaks.

Environment
  • Operating System: windows 10 x64
  • JDK version: 17
  • Visual Studio Code version: 1.75.1
  • Java extension version: v1.15.0
Steps To Reproduce
  1. Set value to 0
  2. format document.

AMetnik avatar Mar 02 '23 10:03 AMetnik

It looks like as expected. Please check the preview via command "Java: Open Java Formatter Settings with Preview"

image

CsCherrYY avatar Mar 13 '23 07:03 CsCherrYY

Yes it is correct that your previewer displays it accurately. But per default the value 0, should disable linesplitting/line-merging, not set it to least possible.

AMetnik avatar Mar 13 '23 07:03 AMetnik

We can find the same behavior in Eclipse. Does your mentioned "disable linesplitting/line-merging" is to do nothing about the code according to the line length? A sample snippet would be helpful.

CsCherrYY avatar Mar 13 '23 08:03 CsCherrYY

Or do you want something like "preserving line breaks"? see also: https://github.com/redhat-developer/vscode-java/issues/2850

CsCherrYY avatar Mar 13 '23 08:03 CsCherrYY

Ahh correct, my appoligize for wasting your time. I see that I have the setting "Never join already wrapped lines" on in Eclipse, which is what I was looking for. Which my guess is that is also what is written about i #2850 ?

AMetnik avatar Mar 13 '23 08:03 AMetnik

I see that I have the setting "Never join already wrapped lines" on in Eclipse, which is what I was looking for.

Yeah, and I guess you need to also set a larger number for lineSplit, since the option only disables joining lines, not disables wrapping lines. Is it right?

CsCherrYY avatar Mar 13 '23 08:03 CsCherrYY

Yes that is correct, i had tried that already, but it kept joining my lines, which was not my intention ;-) Do you know when "Never join already wrapped lines" will be functioning, and how to set it. Because I tried changing it in Eclipse, and there was no difference in the xml :-/

AMetnik avatar Mar 13 '23 10:03 AMetnik

@AMetnik it's org.eclipse.jdt.core.formatter.join_wrapped_lines, when set to false the formatter will never join the wrappered lines.

CsCherrYY avatar Mar 14 '23 01:03 CsCherrYY

Sweet, many many thanks !

AMetnik avatar Mar 14 '23 07:03 AMetnik