mark mode: begin selection at viewport when scrolled up (#19549)

## Summary of the Pull Request
Updates mark mode so that it starts at the viewport's origin (top-left)
if we're not scrolled to the bottom. This is based on the discussion in
#19488.

## Validation Steps Performed
 scrolled at bottom --> mark mode starts at cursor
 scrolled up --> mark mode starts at cursor

Closes #19488
This commit is contained in:
Carlos Zamora
2025-11-11 12:07:52 -08:00
committed by GitHub
parent 965a121a38
commit d2f977aa3d

View File

@@ -364,8 +364,10 @@ void Terminal::ToggleMarkMode()
// NOTE: directly set cursor state. We already should have locked before calling this function. // NOTE: directly set cursor state. We already should have locked before calling this function.
if (!IsSelectionActive()) if (!IsSelectionActive())
{ {
// No selection --> start one at the cursor // If we're scrolled up, use the viewport origin as the selection start.
const auto cursorPos{ _activeBuffer().GetCursor().GetPosition() }; // Otherwise, use the cursor position.
const auto cursorPos = _scrollOffset != 0 ? _GetVisibleViewport().Origin() :
_activeBuffer().GetCursor().GetPosition();
*_selection.write() = SelectionInfo{ *_selection.write() = SelectionInfo{
.start = cursorPos, .start = cursorPos,
.end = cursorPos, .end = cursorPos,