mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 06:07:27 +00:00
Deleted entire whitespace-only lines on Backspace (regardless of indent/scope
This commit is contained in:
1 parent
c171fac4be
commit
295e7cd9cd
1 file changed
+20
@@ -585,6 +585,26 @@ public class GuiScriptTextArea extends GuiNpcTextField {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the current line is whitespace-only, delete the whole line
|
||||
// (including the trailing newline if present). This makes Backspace
|
||||
// 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);
|
||||
if (removeEnd == -1) {
|
||||
removeEnd = text.length();
|
||||
} else {
|
||||
removeEnd = removeEnd + 1; // include the newline
|
||||
}
|
||||
String before = text.substring(0, currCheck.start);
|
||||
String after = removeEnd <= text.length() ? text.substring(removeEnd) : "";
|
||||
setText(before + after);
|
||||
int newCursor = Math.max(0, currCheck.start - 1);
|
||||
selection.reset(newCursor);
|
||||
scrollToCursor();
|
||||
return true;
|
||||
}
|
||||
|
||||
// 3) indent-aware merge: find current line and compute expected indent
|
||||
LineData curr = selection.findCurrentLine(container.lines);
|
||||
if (curr != null && curr.start > 0) {
|
||||
|
||||
Reference in new issue
Block a user