Skip to content

Commit

Permalink
Fixed bug where the selection wouldn't get deleted when you are at th…
Browse files Browse the repository at this point in the history
…e last index
  • Loading branch information
DAMcraft authored and Wide-Cat committed Nov 22, 2023
1 parent 9af9822 commit 66544a9
Showing 1 changed file with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -319,25 +319,24 @@ else if (cursor != selectionStart || cursor != selectionEnd) {
return true;
}
else if (key == GLFW_KEY_DELETE) {
if (cursor < text.length()) {
if (cursor == selectionStart && cursor == selectionEnd) {
String preText = text;
if (cursor < text.length()) {
String preText = text;

int count = mods == (SystemUtils.IS_OS_WINDOWS ? GLFW_MOD_ALT : MinecraftClient.IS_SYSTEM_MAC ? GLFW_MOD_SUPER : GLFW_MOD_CONTROL)
? text.length() - cursor
: (mods == (SystemUtils.IS_OS_WINDOWS ? GLFW_MOD_CONTROL : GLFW_MOD_ALT))
? countToNextSpace(false)
: 1;
int count = mods == (SystemUtils.IS_OS_WINDOWS ? GLFW_MOD_ALT : MinecraftClient.IS_SYSTEM_MAC ? GLFW_MOD_SUPER : GLFW_MOD_CONTROL)
? text.length() - cursor
: (mods == (SystemUtils.IS_OS_WINDOWS ? GLFW_MOD_CONTROL : GLFW_MOD_ALT))
? countToNextSpace(false)
: 1;

text = text.substring(0, cursor) + text.substring(cursor + count);
text = text.substring(0, cursor) + text.substring(cursor + count);

if (!text.equals(preText)) runAction();
if (!text.equals(preText)) runAction();
}
}
else {
clearSelection();
}
}

return true;
}
else if (key == GLFW_KEY_LEFT) {
Expand Down

0 comments on commit 66544a9

Please sign in to comment.