You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Java code formatter is working improperly after single-line conditions, loops, and specifically after multiline method signatures. For example, consider the following code segment:
Now, if you hit Enter after the opening curly brace, the cursor will be jumped right to the next line with unexpected indentation:
Environment
Operating System: Windows 10 22H2
JDK version: javac 17.0.10
Visual Studio Code version: 1.86.2
Java extension version: 1.28.1
Steps To Reproduce
The brief information above represents just one example. Here is more with single-line conditions and loops:
Consider this code segment:
public static List<List<Integer>> combinationSum(
int[] candidates, int target) {
int x = 5;
if (x > 5)
System.out.println("ok");
else
System.out.println("Not ok");
return new ArrayList<>();
}
Have a look after the end of the else statement. It should not be indented in such cases.
Here is the screenshot:
Just as a note, I played around with the examples mentioned here.
It's not the language server that's causing this. textDocument/formattingOnType returns an empty result. It's the indentation rules inherited by our extension : https://code.visualstudio.com/api/language-extensions/language-configuration-guide#indentation-rules . We probably need to update them to increase/decrease indentation in the cases mentioned. If that can't be done, maybe we need to have the language server actually handle these.
The Java code formatter is working improperly after single-line conditions, loops, and specifically after multiline method signatures. For example, consider the following code segment:
Now, if you hit Enter after the opening curly brace, the cursor will be jumped right to the next line with unexpected indentation:
Environment
Steps To Reproduce
The brief information above represents just one example. Here is more with single-line conditions and loops:
Consider this code segment:
Have a look after the end of the
else
statement. It should not be indented in such cases.Here is the screenshot:
The same goes with one-liner loops:
A sample file saved unformatted:
Main.zip
Log file generated by RedHat formatting server:
redhat_server_log.txt
The text was updated successfully, but these errors were encountered: