javavscode icon indicating copy to clipboard operation
javavscode copied to clipboard

Formatter destroys code with syntax errors

Open fvclaus opened this issue 8 months ago • 3 comments

The formatter seems to have trouble handling code with syntax errors, for example:

        if ("foo".contains("bar"))) {
            System.out.println("bar");
        }

will be formatted to

        if ("foo".contains("bar"))
            
         {
            
        }) {
            System.out.println("bar");
        }

This is especially annoying in larger files, where it may destroy code in the same file that is not inside your view. When you find it out, you often can't easily undo it because you might have been editing the code for a while before noticing the damage.

Image

fvclaus avatar Mar 29 '25 11:03 fvclaus

This is a duplicate of #195 (which itself was filed to reopen the original #65 which was closed as "non-reproducible").

anthonyvdotbe avatar Apr 18 '25 11:04 anthonyvdotbe

@fvclaus this issue is very specific to erroneous if cases and a fix is provided in latest available version 24.1.2 , please give it a try and let us know.

naren2605 avatar Oct 10 '25 04:10 naren2605

@naren2605 thanks for looking into this. I am not using this extension anymore, because it had too many issues at the time and didn't provide any benefits over the Red Hat extension

fvclaus avatar Oct 26 '25 18:10 fvclaus