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

Code before:
                if (cursorBelowBottomDist > MinAutoScrollDist)
                {
                    newAutoScrollVelocity = _GetAutoScrollSpeed(cursorBelowBottomDist);
                }
                else if (cursorAboveTopDist > MinAutoScrollDist)
                {
                    newAutoScrollVelocity = -1.0 * _GetAutoScrollSpeed(cursorAboveTopDist);
                }

                if (newAutoScrollVelocity != 0)
                {
                    _TryStartAutoScroll(point, newAutoScrollVelocity);
                }
                else
                {
                    _TryStopAutoScroll(ptr.PointerId());
                }
            }
            const auto terminalPos = _GetTerminalPosition(point.Position());
            if (terminalPos != _lastHoveredCell)
            {
                const auto uri = _terminal->GetHyperlinkAtPosition(terminalPos);
                if (!uri.empty())
                {
                    // Update the tooltip with the URI
                    LinkTip().Content(winrt::box_value(uri));

                    // Set the border thickness so it covers the entire cell
                    const auto charSizeInPixels = CharacterDimensions();
                    const auto htInDips = charSizeInPixels.Height / SwapChainPanel().CompositionScaleY();
                    const auto wtInDips = charSizeInPixels.Width / SwapChainPanel().CompositionScaleX();
                    const Thickness newThickness{ wtInDips, htInDips, 0, 0 };
                    HyperlinkTooltipBorder().BorderThickness(newThickness);

                    // Compute the location of the top left corner of the cell in DIPS
                    const til::size marginsInDips{ til::math::rounding, GetPadding().Left, GetPadding().Top };
                    const til::point startPos{ terminalPos.X, terminalPos.Y };
                    const til::size fontSize{ _actualFont.GetSize() };
                    const til::point posInPixels{ startPos * fontSize };
                    const til::point posInDIPs{ posInPixels / SwapChainPanel().CompositionScaleX() };
                    const til::point locationInDIPs{ posInDIPs + marginsInDips };

                    // Move the border to the top left corner of the cell
                    OverlayCanvas().SetLeft(HyperlinkTooltipBorder(), (locationInDIPs.x() - SwapChainPanel().ActualOffset().x));
                    OverlayCanvas().SetTop(HyperlinkTooltipBorder(), (locationInDIPs.y() - SwapChainPanel().ActualOffset().y));
                }
                _lastHoveredCell = terminalPos;

                const auto newId = _terminal->GetHyperlinkIdAtPosition(terminalPos);
                // If the hyperlink ID changed, trigger a redraw all (so this will happen both when we move
                // onto a link and when we move off a link)

Review comment (suggestion):
Is there a way we can put two textblocks inside the tooltip, one of which is localized to say "ctrl+click to open link" in italic or something?

I'm imagining...

![image](https://user-images.githubusercontent.com/189190/92165627-2fe7b300-edec-11ea-90c4-a315cf0e9662.png)


Code after:
                if (cursorBelowBottomDist > MinAutoScrollDist)
                {
                    newAutoScrollVelocity = _GetAutoScrollSpeed(cursorBelowBottomDist);
                }
                else if (cursorAboveTopDist > MinAutoScrollDist)
                {
                    newAutoScrollVelocity = -1.0 * _GetAutoScrollSpeed(cursorAboveTopDist);
                }

                if (newAutoScrollVelocity != 0)
                {
                    _TryStartAutoScroll(point, newAutoScrollVelocity);
                }
                else
                {
                    _TryStopAutoScroll(ptr.PointerId());
                }
            }
            const auto terminalPos = _GetTerminalPosition(point.Position());
            if (terminalPos != _lastHoveredCell)
            {
                const auto uri = _terminal->GetHyperlinkAtPosition(terminalPos);
                if (!uri.empty())
                {
                    // Update the tooltip with the URI
                    HoveredUri().Text(uri);

                    // Set the border thickness so it covers the entire cell
                    const auto charSizeInPixels = CharacterDimensions();
                    const auto htInDips = charSizeInPixels.Height / SwapChainPanel().CompositionScaleY();
                    const auto wtInDips = charSizeInPixels.Width / SwapChainPanel().CompositionScaleX();
                    const Thickness newThickness{ wtInDips, htInDips, 0, 0 };
                    HyperlinkTooltipBorder().BorderThickness(newThickness);

                    // Compute the location of the top left corner of the cell in DIPS
                    const til::size marginsInDips{ til::math::rounding, GetPadding().Left, GetPadding().Top };
                    const til::point startPos{ terminalPos.X, terminalPos.Y };
                    const til::size fontSize{ _actualFont.GetSize() };
                    const til::point posInPixels{ startPos * fontSize };
                    const til::point posInDIPs{ posInPixels / SwapChainPanel().CompositionScaleX() };
                    const til::point locationInDIPs{ posInDIPs + marginsInDips };

                    // Move the border to the top left corner of the cell
                    OverlayCanvas().SetLeft(HyperlinkTooltipBorder(), (locationInDIPs.x() - SwapChainPanel().ActualOffset().x));
                    OverlayCanvas().SetTop(HyperlinkTooltipBorder(), (locationInDIPs.y() - SwapChainPanel().ActualOffset().y));
                }
                _lastHoveredCell = terminalPos;

                const auto newId = _terminal->GetHyperlinkIdAtPosition(terminalPos);
                // If the hyperlink ID changed, trigger a redraw all (so this will happen both when we move
                // onto a link and when we move off a link)