From 425d6b017a5a62411033b41abefc9403487207cf Mon Sep 17 00:00:00 2001 From: Carlos Zamora Date: Fri, 31 Jan 2025 14:30:51 -0800 Subject: [PATCH] Bugfix: only round to the nearest cell for selection (#18486) ## Summary of the Pull Request Fixes a bug where VT mouse mode would round to the nearest cell when clicking the mouse button. The fix is to round to the nearest cell only when we're selecting text. The other scenarios affected are: - clicking on a hyperlink - vt mouse mode - where the context menu is anchored Really the most notable ones were the first two. So now, we use the position of the cell we clicked on. We only round for selection. ## References and Relevant Issues Follow-up to #18106 ## Detailed Description of the Pull Request / Additional comments ## Validation Steps Performed Opened Midnight Commander in Ubuntu and clicked between the two panes. - Before: threshold was too early to switch between panes - After: threshold is clearly separated between the outline of the two panes --------- Co-authored-by: Dustin L. Howett --- src/cascadia/TerminalControl/ControlInteractivity.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cascadia/TerminalControl/ControlInteractivity.cpp b/src/cascadia/TerminalControl/ControlInteractivity.cpp index f4c0feed2a..0fd2840a58 100644 --- a/src/cascadia/TerminalControl/ControlInteractivity.cpp +++ b/src/cascadia/TerminalControl/ControlInteractivity.cpp @@ -241,7 +241,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation const ::Microsoft::Terminal::Core::ControlKeyStates modifiers, const Core::Point pixelPosition) { - const auto terminalPosition = _getTerminalPosition(til::point{ pixelPosition }, true); + // Un-rounded coordinates; we only round when selecting text + const auto terminalPosition = _getTerminalPosition(til::point{ pixelPosition }, false); const auto altEnabled = modifiers.IsAltPressed(); const auto shiftEnabled = modifiers.IsShiftPressed(); @@ -285,7 +286,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation } const auto isOnOriginalPosition = _lastMouseClickPosNoSelection == pixelPosition; - _core->LeftClickOnTerminal(terminalPosition, + // Rounded coordinates for text selection + _core->LeftClickOnTerminal(_getTerminalPosition(til::point{ pixelPosition }, true), multiClickMapper, altEnabled, shiftEnabled,