From 373f966276aed3c6ff435dff58189496e30a1232 Mon Sep 17 00:00:00 2001 From: Carlos Zamora Date: Tue, 23 Jun 2026 15:48:32 -0700 Subject: [PATCH] Refresh hovered hyperlink on scroll --- src/cascadia/TerminalControl/ControlCore.cpp | 16 ++++++++++++++++ src/cascadia/TerminalControl/ControlCore.h | 1 + 2 files changed, 17 insertions(+) diff --git a/src/cascadia/TerminalControl/ControlCore.cpp b/src/cascadia/TerminalControl/ControlCore.cpp index 3ca144bb4d..f7c0314eec 100644 --- a/src/cascadia/TerminalControl/ControlCore.cpp +++ b/src/cascadia/TerminalControl/ControlCore.cpp @@ -247,6 +247,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation [weakThis = get_weak()](const auto& update) { if (auto core{ weakThis.get() }; core && !core->_IsClosing()) { + // GH#20219: re-evaluate if we're hovering over a hyperlink after scrolling + core->_refreshHoveredCell(); core->ScrollPositionChanged.raise(*core, update); } }); @@ -749,6 +751,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation _terminal->UserScrollViewport(viewTop); } + // GH#20219: re-evaluate if we're hovering over a hyperlink after scrolling + _refreshHoveredCell(); + const auto shared = _shared.lock_shared(); if (shared->outputIdle) { @@ -835,11 +840,22 @@ namespace winrt::Microsoft::Terminal::Control::implementation { _updateHoveredCell(std::optional{ pos }); } + void ControlCore::ClearHoveredCell() { _updateHoveredCell(std::nullopt); } + void ControlCore::_refreshHoveredCell() + { + if (_lastHoveredCell) + { + const auto cell = *_lastHoveredCell; + _lastHoveredCell.reset(); + _updateHoveredCell(cell); + } + } + void ControlCore::_updateHoveredCell(const std::optional terminalPosition) { if (terminalPosition == _lastHoveredCell) diff --git a/src/cascadia/TerminalControl/ControlCore.h b/src/cascadia/TerminalControl/ControlCore.h index 1a03da9dbe..e51154c22b 100644 --- a/src/cascadia/TerminalControl/ControlCore.h +++ b/src/cascadia/TerminalControl/ControlCore.h @@ -353,6 +353,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation void _connectionOutputHandler(winrt::array_view str); void _connectionStateChangedHandler(const TerminalConnection::ITerminalConnection&, const Windows::Foundation::IInspectable&); void _updateHoveredCell(const std::optional terminalPosition); + void _refreshHoveredCell(); void _setOpacity(const float opacity, const bool focused = true); bool _isBackgroundTransparent();