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
I want to get the index change of given cursor when formatting Java code. I noticed that it can be done with formatWithCursor(API) or --cursor-offset(CLI). However, whatever valid offset I try, the result will always be 0. Besides, I have also tried with formatting babel code (builtin in Prettier), which behaved correctly. I wonder how I can fix this. Is this a feature unfinished?
I will show you the example with API (CLI also fails extractly the same)
API Usage with formatWithCursor
import*asprettierfrom"prettier";import*asprettierPluginJavafrom"prettier-plugin-java";constjavaText=` public class HelloWorldExample{public static void main(String args[]){ System.out.println("Hello World !"); }}`;constformattedText=awaitprettier.formatWithCursor(javaText,{cursorOffset: 5,parser: "java",plugins: [prettierPluginJava.default],});
Prettier-Java 2.6.0
Detail
I want to get the index change of given cursor when formatting Java code. I noticed that it can be done with
formatWithCursor
(API) or--cursor-offset
(CLI). However, whatever valid offset I try, the result will always be 0. Besides, I have also tried with formatting babel code (builtin in Prettier), which behaved correctly. I wonder how I can fix this. Is this a feature unfinished?I will show you the example with API (CLI also fails extractly the same)
API Usage with
formatWithCursor
Output:
Expected output:
The text was updated successfully, but these errors were encountered: