@@ -104,14 +104,14 @@ public static String formatIndentation(String text, IndentationType type) {
104104 boolean startOfLine = true ;
105105 for (int i = 0 ; i < text .length (); i ++) {
106106 char current = text .charAt (i );
107+ if (startOfLine && current == ' ' ) {
108+ continue ;
109+ }
107110 builder .append (current );
108111 if (current == '\n' ) {
109112 builder .append (type .getPattern ().repeat (Math .max (numberOfBrackets , 0 )));
110113 startOfLine = true ;
111114 }
112- if (startOfLine && current == ' ' ) {
113- builder .deleteCharAt (builder .length () - 1 );
114- }
115115 switch (currentState ) {
116116 case CODE -> {
117117 switch (current ) {
@@ -122,8 +122,12 @@ public static String formatIndentation(String text, IndentationType type) {
122122 builder .replace (builder .length () - type .getNumberOfChars () - 1 , builder .length (), "}" );
123123 }
124124 }
125- case '\'' -> currentState = IndentationState .CHARACTER ;
126- case '\"' -> currentState = IndentationState .STRING ;
125+ case '\'' -> {
126+ currentState = IndentationState .CHARACTER ;
127+ }
128+ case '\"' -> {
129+ currentState = IndentationState .STRING ;
130+ }
127131 case '/' -> {
128132 if (i + 1 < text .length ()) {
129133 if (text .charAt (i + 1 ) == '/' ) {
@@ -136,17 +140,13 @@ public static String formatIndentation(String text, IndentationType type) {
136140 }
137141 }
138142 case STRING -> {
139- if (current == '\"' ) {
140- if (!isEscaped (builder , builder .length () - 1 )) {
141- currentState = IndentationState .CODE ;
142- }
143+ if (current == '\"' && !isEscaped (builder , builder .length () - 1 )) {
144+ currentState = IndentationState .CODE ;
143145 }
144146 }
145147 case CHARACTER -> {
146- if (current == '\'' ) {
147- if (!isEscaped (builder , builder .length () - 1 )) {
148- currentState = IndentationState .CODE ;
149- }
148+ if (current == '\'' && !isEscaped (builder , builder .length () - 1 )) {
149+ currentState = IndentationState .CODE ;
150150 }
151151 }
152152 case SINGLE_LINE_COMMENT -> {
0 commit comments