From 118b258244575c49f9a3eb785e7dfcbb4c454d4b Mon Sep 17 00:00:00 2001 From: yoyosource Date: Wed, 28 Dec 2022 11:35:35 +0100 Subject: [PATCH] Fix selection errors --- .../advancedscripts/screen/ScriptEditScreen.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/zonlykroks/advancedscripts/screen/ScriptEditScreen.java b/src/main/java/de/zonlykroks/advancedscripts/screen/ScriptEditScreen.java index 581bde6..6f0ea59 100644 --- a/src/main/java/de/zonlykroks/advancedscripts/screen/ScriptEditScreen.java +++ b/src/main/java/de/zonlykroks/advancedscripts/screen/ScriptEditScreen.java @@ -147,8 +147,8 @@ public class ScriptEditScreen extends Screen { boolean hasSelection = savedCursorY != -1 && savedCursorX != -1; int minSelectionY = Math.min(cursorY, savedCursorY); int maxSelectionY = Math.max(cursorY, savedCursorY); - int minSelectionX = minSelectionY == cursorY ? cursorX : savedCursorX; - int maxSelectionX = maxSelectionY == cursorY ? cursorX : savedCursorX; + int minSelectionX = (minSelectionY == maxSelectionY ? Math.min(cursorX, savedCursorX) : (minSelectionY == cursorY ? cursorX : savedCursorX)); + int maxSelectionX = (minSelectionY == maxSelectionY ? Math.max(cursorX, savedCursorX) : (maxSelectionY == cursorY ? cursorX : savedCursorX)); int lineNumberText = scroll + 1; MutableInt lineNumber = new MutableInt(); @@ -369,8 +369,8 @@ public class ScriptEditScreen extends Screen { } int minSelectionY = Math.min(savedCursorY, cursorY); int maxSelectionY = Math.max(savedCursorY, cursorY); - int minSelectionX = minSelectionY == cursorY ? cursorX : savedCursorX; - int maxSelectionX = maxSelectionY == cursorY ? cursorX : savedCursorX; + int minSelectionX = (minSelectionY == maxSelectionY ? Math.min(cursorX, savedCursorX) : (minSelectionY == cursorY ? cursorX : savedCursorX)); + int maxSelectionX = (minSelectionY == maxSelectionY ? Math.max(cursorX, savedCursorX) : (maxSelectionY == cursorY ? cursorX : savedCursorX)); StringBuilder builder = new StringBuilder(); for (int i = minSelectionY; i <= maxSelectionY; i++) {