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

Code before:
        const auto terminalPosition = _GetTerminalPosition(cursorPosition);

        if (!_focused && _settings.FocusFollowMouse())
        {
            _FocusFollowMouseRequestedHandlers(*this, nullptr);
        }

        if (ptr.PointerDeviceType() == Windows::Devices::Input::PointerDeviceType::Mouse || ptr.PointerDeviceType() == Windows::Devices::Input::PointerDeviceType::Pen)
        {
            // Short-circuit isReadOnly check to avoid warning dialog
            if (_focused && !_isReadOnly && _CanSendVTMouseInput())
            {
                _TrySendMouseEvent(point);
                args.Handled(true);
            }
            else if (_focused && point.Properties().IsLeftButtonPressed())
            {
                auto lock = _terminal->LockForWriting();

                if (_singleClickTouchdownPos)
                {
                    // Figure out if the user's moved a quarter of a cell's smaller axis away from the clickdown point
                    auto& touchdownPoint{ *_singleClickTouchdownPos };
                    auto distance{ std::sqrtf(std::powf(cursorPosition.X - touchdownPoint.X, 2) + std::powf(cursorPosition.Y - touchdownPoint.Y, 2)) };
                    const til::size fontSize{ _actualFont.GetSize() };

                    const auto fontSizeInDips = fontSize.scale(til::math::rounding, 1.0f / _renderEngine->GetScaling());
                    if (distance >= (std::min(fontSizeInDips.width(), fontSizeInDips.height()) / 4.f))
                    {
                        _terminal->SetSelectionAnchor(_GetTerminalPosition(touchdownPoint));
                        // stop tracking the touchdown point
                        _singleClickTouchdownPos = std::nullopt;
                    }
                }

                _SetEndSelectionPointAtCursor(cursorPosition);

                const double cursorBelowBottomDist = cursorPosition.Y - SwapChainPanel().Margin().Top - SwapChainPanel().ActualHeight();
                const double cursorAboveTopDist = -1 * cursorPosition.Y + SwapChainPanel().Margin().Top;

                constexpr double MinAutoScrollDist = 2.0; // Arbitrary value
                double newAutoScrollVelocity = 0.0;
                if (cursorBelowBottomDist > MinAutoScrollDist)
                {
                    newAutoScrollVelocity = _GetAutoScrollSpeed(cursorBelowBottomDist);
                }
                else if (cursorAboveTopDist > MinAutoScrollDist)
                {
                    newAutoScrollVelocity = -1.0 * _GetAutoScrollSpeed(cursorAboveTopDist);
                }


Review comment (suggestion):
this all seems unrelated. But if we're doing this, I think you can remove 1437 too? We set args.Handled to true on line 1519.

Code after:
    {
        if (_closing)
        {
            return;
        }

        _RestorePointerCursorHandlers(*this, nullptr);

        const auto ptr = args.Pointer();
        const auto point = args.GetCurrentPoint(*this);
        const auto cursorPosition = point.Position();
        const auto terminalPosition = _GetTerminalPosition(cursorPosition);

        if (!_focused && _settings.FocusFollowMouse())
        {
            _FocusFollowMouseRequestedHandlers(*this, nullptr);
        }

        if (ptr.PointerDeviceType() == Windows::Devices::Input::PointerDeviceType::Mouse || ptr.PointerDeviceType() == Windows::Devices::Input::PointerDeviceType::Pen)
        {
            // Short-circuit isReadOnly check to avoid warning dialog
            if (_focused && !_isReadOnly && _CanSendVTMouseInput())
            {
                _TrySendMouseEvent(point);
            }
            else if (_focused && point.Properties().IsLeftButtonPressed())
            {
                auto lock = _terminal->LockForWriting();

                if (_singleClickTouchdownPos)
                {
                    // Figure out if the user's moved a quarter of a cell's smaller axis away from the clickdown point
                    auto& touchdownPoint{ *_singleClickTouchdownPos };
                    auto distance{ std::sqrtf(std::powf(cursorPosition.X - touchdownPoint.X, 2) + std::powf(cursorPosition.Y - touchdownPoint.Y, 2)) };
                    const til::size fontSize{ _actualFont.GetSize() };

                    const auto fontSizeInDips = fontSize.scale(til::math::rounding, 1.0f / _renderEngine->GetScaling());
                    if (distance >= (std::min(fontSizeInDips.width(), fontSizeInDips.height()) / 4.f))
                    {
                        _terminal->SetSelectionAnchor(_GetTerminalPosition(touchdownPoint));
                        // stop tracking the touchdown point
                        _singleClickTouchdownPos = std::nullopt;
                    }
                }

                _SetEndSelectionPointAtCursor(cursorPosition);

                const double cursorBelowBottomDist = cursorPosition.Y - SwapChainPanel().Margin().Top - SwapChainPanel().ActualHeight();
                const double cursorAboveTopDist = -1 * cursorPosition.Y + SwapChainPanel().Margin().Top;

                constexpr double MinAutoScrollDist = 2.0; // Arbitrary value