From 6aebcfc63cce7df53c80107d465dcc21b06414e6 Mon Sep 17 00:00:00 2001 From: bigguy345 Date: Mon, 22 Dec 2025 03:11:45 +0200 Subject: [PATCH] Fixed tab/backspace crash --- .../java/noppes/npcs/client/gui/util/GuiScriptTextArea.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 69d1c48f7..ab785678f 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java @@ -1447,13 +1447,13 @@ public class GuiScriptTextArea extends GuiNpcTextField { // intuitive on blank/indented lines outside any recognized scope. LineData currCheck = selection.findCurrentLine(container.lines); if (currCheck != null && currCheck.text.trim().length() == 0) { - int removeEnd = text.indexOf('\n', currCheck.start-1); + int removeEnd = text.indexOf('\n', currCheck.start); if (removeEnd == -1) { removeEnd = text.length(); } else { removeEnd = removeEnd + 1; // include the newline } - String before = text.substring(0, currCheck.start-1); + String before = text.substring(0, Math.max(0, currCheck.start)); String after = removeEnd <= text.length() ? text.substring(removeEnd) : ""; setText(before + after); int newCursor = Math.max(0, currCheck.start - 1); @@ -1493,7 +1493,7 @@ public class GuiScriptTextArea extends GuiNpcTextField { } else { // Merge current line content with the previous line preserving spacing int contentStart = curr.start + actualIndent; - String before = text.substring(0, newlinePos); + String before = newlinePos >= 0 ? text.substring(0, newlinePos) : ""; String content = contentStart <= text.length() ? text.substring(contentStart) : ""; // Decide whether a space is needed between concatenated fragments.