From d2f977aa3d334664bcb3adf0c764aca1c8e0032f Mon Sep 17 00:00:00 2001 From: Carlos Zamora Date: Tue, 11 Nov 2025 12:07:52 -0800 Subject: [PATCH] mark mode: begin selection at viewport when scrolled up (#19549) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 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 --- src/cascadia/TerminalCore/TerminalSelection.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cascadia/TerminalCore/TerminalSelection.cpp b/src/cascadia/TerminalCore/TerminalSelection.cpp index 11286c4206..f316cc782a 100644 --- a/src/cascadia/TerminalCore/TerminalSelection.cpp +++ b/src/cascadia/TerminalCore/TerminalSelection.cpp @@ -364,8 +364,10 @@ void Terminal::ToggleMarkMode() // NOTE: directly set cursor state. We already should have locked before calling this function. if (!IsSelectionActive()) { - // No selection --> start one at the cursor - const auto cursorPos{ _activeBuffer().GetCursor().GetPosition() }; + // If we're scrolled up, use the viewport origin as the selection start. + // Otherwise, use the cursor position. + const auto cursorPos = _scrollOffset != 0 ? _GetVisibleViewport().Origin() : + _activeBuffer().GetCursor().GetPosition(); *_selection.write() = SelectionInfo{ .start = cursorPos, .end = cursorPos,