From 02be805c144c74794b3622697f7f3c2c89406b33 Mon Sep 17 00:00:00 2001 From: bigguy345 Date: Thu, 18 Dec 2025 02:06:14 +0200 Subject: [PATCH] Another braces scaffold generation bug fixed --- .../noppes/npcs/client/gui/util/GuiScriptTextArea.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java b/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java index 8b6d5c993..3cbafa413 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java @@ -695,6 +695,16 @@ public class GuiScriptTextArea extends GuiNpcTextField { String before = getSelectionBeforeText(); String after = getSelectionAfterText(); + // If there is non-empty code on the same line after the brace (before the next newline), + // treat it as code that should be moved into the newly created inner line. In that case + // just insert the child indent and return — do not insert the closing brace before that code. + int firstNewline = after.indexOf('\n'); + String leadingSegment = firstNewline == -1 ? after : after.substring(0, firstNewline); + if (leadingSegment.trim().length() > 0) { + addText("\n" + childIndent); + return true; + } + // Determine whether this opening brace already has a matching closing // brace at the same scope (and indent). Prefer using the brace-span // computation which skips strings/comments and handles nesting.