Repository: microsoft/terminal
File: src/cascadia/TerminalControl/ControlInteractivity.cpp (C++)

Code before:
            {
                _singleClickTouchdownPos = pixelPosition;

                if (!_core->HasSelection())
                {
                    _lastMouseClickPosNoSelection = pixelPosition;
                }
            }
            const auto isOnOriginalPosition = _lastMouseClickPosNoSelection == pixelPosition;

            _core->LeftClickOnTerminal(terminalPosition,
                                       multiClickMapper,
                                       altEnabled,
                                       shiftEnabled,
                                       isOnOriginalPosition,
                                       _selectionNeedsToBeCopied);

            if (_core->HasSelection())
            {
                // GH#9787: if selection is active we don't want to track the touchdown position
                // so that dragging the mouse will extend the selection rather than starting the new one
                _singleClickTouchdownPos = std::nullopt;
            }
        }
        else if (WI_IsFlagSet(buttonState, MouseButtonState::IsRightButtonDown))
        {
            // CopyOnSelect right click always pastes
            if (_core->CopyOnSelect() || !_core->HasSelection())
            {
                RequestPasteTextFromClipboard();
            }
            else
            {
                CopySelectionToClipboard(shiftEnabled, nullptr);
            }
        }
    }

    void ControlInteractivity::TouchPressed(const Core::Point contactPoint)
    {
        _touchAnchor = contactPoint;
    }

    void ControlInteractivity::PointerMoved(Control::MouseButtonState buttonState,
                                            const unsigned int pointerUpdateKind,
                                            const ::Microsoft::Terminal::Core::ControlKeyStates modifiers,
                                            const bool focused,
                                            const Core::Point pixelPosition,
                                            const bool pointerPressedInBounds)
    {
        const auto terminalPosition = _getTerminalPosition(til::point{ pixelPosition });

Review comment (suggestion):
It could be helpful to mention here that `CopySelectionToClipboard` returns `false` if the selection is empty, which results in our "unique" right-click behavior (copy if something's selected, paste if it isn't).

Code after:
                _singleClickTouchdownPos = pixelPosition;

                if (!_core->HasSelection())
                {
                    _lastMouseClickPosNoSelection = pixelPosition;
                }
            }
            const auto isOnOriginalPosition = _lastMouseClickPosNoSelection == pixelPosition;

            _core->LeftClickOnTerminal(terminalPosition,
                                       multiClickMapper,
                                       altEnabled,
                                       shiftEnabled,
                                       isOnOriginalPosition,
                                       _selectionNeedsToBeCopied);

            if (_core->HasSelection())
            {
                // GH#9787: if selection is active we don't want to track the touchdown position
                // so that dragging the mouse will extend the selection rather than starting the new one
                _singleClickTouchdownPos = std::nullopt;
            }
        }
        else if (WI_IsFlagSet(buttonState, MouseButtonState::IsRightButtonDown))
        {
            // Try to copy the text and clear the selection
            const auto successfulCopy = CopySelectionToClipboard(shiftEnabled, nullptr);
            _core->ClearSelection();
            if (_core->CopyOnSelect() || !successfulCopy)
            {
                // CopyOnSelect: right click always pastes!
                // Otherwise: no selection --> paste
                RequestPasteTextFromClipboard();
            }
        }
    }

    void ControlInteractivity::TouchPressed(const Core::Point contactPoint)
    {
        _touchAnchor = contactPoint;
    }

    void ControlInteractivity::PointerMoved(Control::MouseButtonState buttonState,
                                            const unsigned int pointerUpdateKind,
                                            const ::Microsoft::Terminal::Core::ControlKeyStates modifiers,
                                            const bool focused,
                                            const Core::Point pixelPosition,
                                            const bool pointerPressedInBounds)
    {
        const auto terminalPosition = _getTerminalPosition(til::point{ pixelPosition });