From 66544a9415fe5327d586bb3b9c297a49c2eaf80f Mon Sep 17 00:00:00 2001 From: DAM <43420467+DAMcraft@users.noreply.github.com> Date: Fri, 17 Nov 2023 22:06:31 +0100 Subject: [PATCH] Fixed bug where the selection wouldn't get deleted when you are at the last index --- .../gui/widgets/input/WTextBox.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/gui/widgets/input/WTextBox.java b/src/main/java/meteordevelopment/meteorclient/gui/widgets/input/WTextBox.java index dd44393eb6..61846c92cb 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/widgets/input/WTextBox.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/widgets/input/WTextBox.java @@ -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) {