Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/cascadia/TerminalCore/Terminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1297,9 +1297,15 @@ void Terminal::ScrollToSearchHighlight(til::CoordType searchScrollOffset)
if (_searchHighlightFocused < _searchHighlights.size())
{
const auto focused = til::at(_searchHighlights, _searchHighlightFocused);
const auto adjustedStart = til::point{ focused.start.x, std::max(0, focused.start.y - searchScrollOffset) };
const auto adjustedEnd = til::point{ focused.end.x, std::max(0, focused.end.y - searchScrollOffset) };
_ScrollToPoints(adjustedStart, adjustedEnd);

// Only adjust the y coordinates if "start" is in a row that would be covered by the search box
auto adjustedStart = focused.start;
const auto firstVisibleRow = _VisibleStartIndex();
if (focused.start.y > firstVisibleRow && focused.start.y < firstVisibleRow + searchScrollOffset)
{
adjustedStart.y = std::max(0, focused.start.y - searchScrollOffset);
}
_ScrollToPoints(adjustedStart, focused.end);
}
}

Expand Down
19 changes: 2 additions & 17 deletions src/cascadia/TerminalCore/terminalrenderdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,29 +152,14 @@ const til::point_span* Terminal::GetSearchHighlightFocused() const noexcept
// - The updated scroll offset
til::CoordType Terminal::_ScrollToPoints(const til::point coordStart, const til::point coordEnd)
{
auto notifyScrollChange = false;
if (coordStart.y < _VisibleStartIndex())
{
// recalculate the scrollOffset
_scrollOffset = ViewStartIndex() - coordStart.y;
notifyScrollChange = true;
_ScrollToPoint(coordStart);
}
else if (coordEnd.y > _VisibleEndIndex())
{
// recalculate the scrollOffset, note that if the found text is
// beneath the current visible viewport, it may be within the
// current mutableViewport and the scrollOffset will be smaller
// than 0
_scrollOffset = std::max(0, ViewStartIndex() - coordStart.y);
notifyScrollChange = true;
_ScrollToPoint(coordEnd);
}

if (notifyScrollChange)
{
_activeBuffer().TriggerScroll();
_NotifyScrollEvent();
}

return _VisibleStartIndex();
}

Expand Down