FULLY fixed phantom trailing line bug (Backspace logic was adding an extra index)

This commit is contained in:
bigguy345 committed 2025-12-20 18:23:52 +02:00
1 parent b4fb4765f5
commit 16f894baca
1 file changed
+2 -2
@@ -1174,13 +1174,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);
int removeEnd = text.indexOf('\n', currCheck.start-1);
if (removeEnd == -1) {
removeEnd = text.length();
} else {
removeEnd = removeEnd + 1; // include the newline
}
String before = text.substring(0, currCheck.start);
String before = text.substring(0, currCheck.start-1);
String after = removeEnd <= text.length() ? text.substring(removeEnd) : "";
setText(before + after);
int newCursor = Math.max(0, currCheck.start - 1);