mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-13 05:27:37 +00:00
Fixed auto {} brace insertion not respecting existing } that has different indent/whitespaces
This commit is contained in:
1 parent
0c842a22b9
commit
2ca145b264
1 file changed
+11
@@ -1976,6 +1976,17 @@ public class GuiScriptTextArea extends GuiNpcTextField {
|
||||
String childIndent = indent + " ";
|
||||
String after = getSelectionAfterText();
|
||||
|
||||
// If the next non-whitespace char is '}', don't insert another closer.
|
||||
int nextNonWs = 0;
|
||||
while (nextNonWs < after.length() && Character.isWhitespace(after.charAt(nextNonWs))) {
|
||||
nextNonWs++;
|
||||
}
|
||||
if (nextNonWs < after.length() && after.charAt(nextNonWs) == '}') {
|
||||
addText("\n" + childIndent);
|
||||
scrollToCursor();
|
||||
return true;
|
||||
}
|
||||
|
||||
int firstNewline = after.indexOf('\n');
|
||||
String leadingSegment = firstNewline == -1 ? after : after.substring(0, firstNewline);
|
||||
if (leadingSegment.trim().length() > 0) {
|
||||
|
||||
Reference in new issue
Block a user