[PR #19550] mark mode: begin selection at focused search result #31876

Closed
opened 2026-01-31 09:50:07 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/19550

State: closed
Merged: Yes


Summary of the Pull Request

Searching in terminal highlights all search results. However, those results are considered separate from a selection. In the past, the highlighted result would be selected, resulting in it being the initial position for mark mode. Now that it's separate, mark mode doesn't start there.

To fix this, there's 2 changes here:

  1. When we exit the search, we now select the focused search result. This becomes the initial position for mark mode.
  2. When we're in the middle of a search and mark mode becomes enabled, the focused search result becomes the initial position for mark mode.

With this change, mark mode's initial position is determined in this order:

  1. the position of an active selection
  2. the position of the focused search result (if one is available)
  3. the top-left position of the viewport (if there is a scrollback) (see #19549)
  4. the current cursor position

Validation Steps Performed

Entering mark mode in scenario X results in a starting position of Y:
selected text during a search --> selected text

  • NOTE: this seems to only occur if you start a search, then manually click on the terminal to bring focus there, but keep the search results active

performed a search and results are available -->focused search result
performed a search and no results are available

  • scrolled up --> top-left of viewport
  • no scrollback --> cursor position

performed a search, got results, then closed search --> focused search result

Closes #19358

**Original Pull Request:** https://github.com/microsoft/terminal/pull/19550 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request Searching in terminal highlights all search results. However, those results are considered separate from a selection. In the past, the highlighted result would be selected, resulting in it being the initial position for mark mode. Now that it's separate, mark mode doesn't start there. To fix this, there's 2 changes here: 1. When we exit the search, we now select the focused search result. This becomes the initial position for mark mode. 2. When we're in the middle of a search and mark mode becomes enabled, the focused search result becomes the initial position for mark mode. With this change, mark mode's initial position is determined in this order: 1. the position of an active selection 2. the position of the focused search result (if one is available) 3. the top-left position of the viewport (if there is a scrollback) (see #19549) 4. the current cursor position ## Validation Steps Performed Entering mark mode in scenario X results in a starting position of Y: ✅ selected text during a search --> selected text - NOTE: this seems to only occur if you start a search, then manually click on the terminal to bring focus there, but keep the search results active ✅ performed a search and results are available -->focused search result ✅ performed a search and no results are available - scrolled up --> top-left of viewport - no scrollback --> cursor position ✅ performed a search, got results, then closed search --> focused search result Closes #19358
claunia added the pull-request label 2026-01-31 09:50:07 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#31876