From 9798b30c76c032393854280389fa5a9c75383ac9 Mon Sep 17 00:00:00 2001 From: agnostic-apollo Date: Wed, 13 Oct 2021 22:48:37 +0500 Subject: [PATCH] Fixed: Fix issue where menu wouldn't show when text on bottom row of terminal was selected Closes #2233 --- .../textselection/TextSelectionCursorController.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/terminal-view/src/main/java/com/termux/view/textselection/TextSelectionCursorController.java b/terminal-view/src/main/java/com/termux/view/textselection/TextSelectionCursorController.java index 253e8dea..09e9ba22 100644 --- a/terminal-view/src/main/java/com/termux/view/textselection/TextSelectionCursorController.java +++ b/terminal-view/src/main/java/com/termux/view/textselection/TextSelectionCursorController.java @@ -183,14 +183,19 @@ public class TextSelectionCursorController implements CursorController { int y1 = Math.round((mSelY1 - 1 - terminalView.getTopRow()) * terminalView.mRenderer.getFontLineSpacing()); int y2 = Math.round((mSelY2 + 1 - terminalView.getTopRow()) * terminalView.mRenderer.getFontLineSpacing()); - if (x1 > x2) { int tmp = x1; x1 = x2; x2 = tmp; } - outRect.set(x1, y1 + mHandleHeight, x2, y2 + mHandleHeight); + int terminalBottom = terminalView.getBottom(); + int top = y1 + mHandleHeight; + int bottom = y2 + mHandleHeight; + if (top > terminalBottom) top = terminalBottom; + if (bottom > terminalBottom) bottom = terminalBottom; + + outRect.set(x1, top, x2, bottom); } }, ActionMode.TYPE_FLOATING); }