File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
core/src/main/java/net/j4c0b3y/api/config Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -144,18 +144,25 @@ public String format(String content) {
144144 List <String > formatted = new ArrayList <>();
145145 String [] lines = content .split ("\n " );
146146
147- int previous = -1 ;
147+ int previousIndentation = -1 ;
148+ boolean previousComment = false ;
148149
149150 for (int i = 0 ; i < lines .length ; i ++) {
150151 if (lines [i ].isEmpty ()) continue ;
151152
152- int current = StringUtils .getIndentation (lines [i ]);
153+ int currentIndentation = StringUtils .getIndentation (lines [i ]);
154+ boolean currentComment = lines [i ].trim ().startsWith ("#" );
153155
154- if (current == 0 && previous > 0 ) {
156+ boolean comment = currentComment && !previousComment && previousIndentation >= currentIndentation ;
157+ boolean section = currentIndentation == 0 && previousIndentation > 0 && !previousComment ;
158+
159+ if (comment || section ) {
155160 lines [i ] = "\n " + lines [i ];
156161 }
157162
158- previous = current ;
163+ previousIndentation = currentIndentation ;
164+ previousComment = currentComment ;
165+
159166 formatted .add (lines [i ]);
160167 }
161168
You can’t perform that action at this time.
0 commit comments