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

Code before:
        // again to bring it up.
        InputPane::GetForCurrentView().TryShow();

        if (!_focused)
        {
            Focus(FocusState::Pointer);
        }

        if (ptr.PointerDeviceType() == Windows::Devices::Input::PointerDeviceType::Mouse || ptr.PointerDeviceType() == Windows::Devices::Input::PointerDeviceType::Pen)
        {
            const auto modifiers = static_cast<uint32_t>(args.KeyModifiers());
            // static_cast to a uint32_t because we can't use the WI_IsFlagSet
            // macro directly with a VirtualKeyModifiers
            const auto altEnabled = WI_IsFlagSet(modifiers, static_cast<uint32_t>(VirtualKeyModifiers::Menu));
            const auto shiftEnabled = WI_IsFlagSet(modifiers, static_cast<uint32_t>(VirtualKeyModifiers::Shift));
            const auto ctrlEnabled = WI_IsFlagSet(modifiers, static_cast<uint32_t>(VirtualKeyModifiers::Control));

            auto lock = _terminal->LockForWriting();
            const auto cursorPosition = point.Position();
            const auto terminalPosition = _GetTerminalPosition(cursorPosition);

            // GH#9396: we prioritize hyper-link over VT mouse events
            if (point.Properties().IsLeftButtonPressed() && ctrlEnabled && !_terminal->GetHyperlinkAtPosition(terminalPosition).empty())
            {
                // Handle hyper-link only on the first click to prevent multiple activations
                auto clickCount = _NumberOfClicks(cursorPosition, point.Timestamp());
                if (clickCount == 1)
                {
                    _HyperlinkHandler(_terminal->GetHyperlinkAtPosition(terminalPosition));
                }
            }
            else if (_CanSendVTMouseInput())
            {
                _TrySendMouseEvent(point);
            }
            else if (point.Properties().IsLeftButtonPressed())
            {
                // Update the selection appropriately
                // handle ALT key
                _terminal->SetBlockSelection(altEnabled);

                auto clickCount = _NumberOfClicks(cursorPosition, point.Timestamp());

                // This formula enables the number of clicks to cycle properly between single-, double-, and triple-click.
                // To increase the number of acceptable click states, simply increment MAX_CLICK_COUNT and add another if-statement
                const unsigned int MAX_CLICK_COUNT = 3;
                const auto multiClickMapper = clickCount > MAX_CLICK_COUNT ? ((clickCount + MAX_CLICK_COUNT - 1) % MAX_CLICK_COUNT) + 1 : clickCount;

                ::Terminal::SelectionExpansionMode mode = ::Terminal::SelectionExpansionMode::Cell;
                if (multiClickMapper == 1)
                {

Review comment (suggestion):
```suggestion
                const auto clickCount = _NumberOfClicks(cursorPosition, point.Timestamp());
```

Code after:
        // again to bring it up.
        InputPane::GetForCurrentView().TryShow();

        if (!_focused)
        {
            Focus(FocusState::Pointer);
        }

        if (ptr.PointerDeviceType() == Windows::Devices::Input::PointerDeviceType::Mouse || ptr.PointerDeviceType() == Windows::Devices::Input::PointerDeviceType::Pen)
        {
            const auto modifiers = static_cast<uint32_t>(args.KeyModifiers());
            // static_cast to a uint32_t because we can't use the WI_IsFlagSet
            // macro directly with a VirtualKeyModifiers
            const auto altEnabled = WI_IsFlagSet(modifiers, static_cast<uint32_t>(VirtualKeyModifiers::Menu));
            const auto shiftEnabled = WI_IsFlagSet(modifiers, static_cast<uint32_t>(VirtualKeyModifiers::Shift));
            const auto ctrlEnabled = WI_IsFlagSet(modifiers, static_cast<uint32_t>(VirtualKeyModifiers::Control));

            auto lock = _terminal->LockForWriting();
            const auto cursorPosition = point.Position();
            const auto terminalPosition = _GetTerminalPosition(cursorPosition);

            // GH#9396: we prioritize hyper-link over VT mouse events
            if (point.Properties().IsLeftButtonPressed() && ctrlEnabled && !_terminal->GetHyperlinkAtPosition(terminalPosition).empty())
            {
                // Handle hyper-link only on the first click to prevent multiple activations
                const auto clickCount = _NumberOfClicks(cursorPosition, point.Timestamp());
                if (clickCount == 1)
                {
                    _HyperlinkHandler(_terminal->GetHyperlinkAtPosition(terminalPosition));
                }
            }
            else if (_CanSendVTMouseInput())
            {
                _TrySendMouseEvent(point);
            }
            else if (point.Properties().IsLeftButtonPressed())
            {
                // Update the selection appropriately
                // handle ALT key
                _terminal->SetBlockSelection(altEnabled);

                const auto clickCount = _NumberOfClicks(cursorPosition, point.Timestamp());

                // This formula enables the number of clicks to cycle properly between single-, double-, and triple-click.
                // To increase the number of acceptable click states, simply increment MAX_CLICK_COUNT and add another if-statement
                const unsigned int MAX_CLICK_COUNT = 3;
                const auto multiClickMapper = clickCount > MAX_CLICK_COUNT ? ((clickCount + MAX_CLICK_COUNT - 1) % MAX_CLICK_COUNT) + 1 : clickCount;

                ::Terminal::SelectionExpansionMode mode = ::Terminal::SelectionExpansionMode::Cell;
                if (multiClickMapper == 1)
                {