Fix NPE when inserting new line anywhere but at the end
This commit is contained in:
@@ -252,7 +252,7 @@ public abstract class AbstractGuiTextArea<T extends AbstractGuiTextArea<T>>
|
||||
newText[cursorY + 1] = text[cursorY].substring(cursorX);
|
||||
|
||||
if (cursorY + 1 < text.length) {
|
||||
System.arraycopy(text, cursorY + 1, newText, cursorY + 1, text.length - cursorY - 1);
|
||||
System.arraycopy(text, cursorY + 1, newText, cursorY + 2, text.length - cursorY - 1);
|
||||
}
|
||||
text = newText;
|
||||
selectionX = cursorX = 0;
|
||||
|
||||
@@ -250,7 +250,7 @@ public class GuiTextArea extends Gui implements GuiElement, GuiOutsideClickableE
|
||||
newText[cursorY + 1] = text[cursorY].substring(cursorX);
|
||||
|
||||
if (cursorY + 1 < text.length) {
|
||||
System.arraycopy(text, cursorY + 1, newText, cursorY + 1, text.length - cursorY - 1);
|
||||
System.arraycopy(text, cursorY + 1, newText, cursorY + 2, text.length - cursorY - 1);
|
||||
}
|
||||
text = newText;
|
||||
selectionX = cursorX = 0;
|
||||
@@ -510,6 +510,7 @@ public class GuiTextArea extends Gui implements GuiElement, GuiOutsideClickableE
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (GuiScreen.isCtrlKeyDown()) {
|
||||
switch (keyCode) {
|
||||
case Keyboard.KEY_A: // Select all
|
||||
@@ -623,6 +624,14 @@ public class GuiTextArea extends Gui implements GuiElement, GuiOutsideClickableE
|
||||
selectionX = cursorX;
|
||||
selectionY = cursorY;
|
||||
}
|
||||
} finally {
|
||||
System.out.println(cursorX + "/" + cursorY);
|
||||
System.out.println(selectionX + "/" + selectionY);
|
||||
System.out.println("Lines (" + text.length + "): ");
|
||||
for (String line : text) {
|
||||
System.out.println(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user