[PR #18798] Fix color selection off-by-one error and dangling Y-beam #31609

Open
opened 2026-01-31 09:48:22 +00:00 by claunia · 0 comments
Owner

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

State: closed
Merged: Yes


Summary of the Pull Request

Fixes a bug where the color selection actions would color one more character than they needed to.
Also fixes a bug where if mark mode was used to create the selection, a dangling y-beam would be left over after executing the action.
 

References and Relevant Issues

Regressed in #18106

Detailed Description of the Pull Request / Additional comments

  • TextBuffer::SpanLength was only used once (in Terminal::ColorSelection). All it really did was call Viewport::CompareInBounds. So I deduplicated it.
    • Funny enough, the +1 added there was no longer correct because the incoming coordinates were switched from an inclusive range to an exclusive range.
  • To fix the dangling y-beam, I added a call to _updateSelectionUI in ControlCore::ColorSelection. This heuristic is used throughout the file for other selection-related functions.

Validation Steps Performed

color selection action highlights reference(s) to selected text
color selection action highlights reference(s) to selected text when text is at right boundary
dangling y-beam disappears after executing color selection actions

Closes #18739

**Original Pull Request:** https://github.com/microsoft/terminal/pull/18798 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request Fixes a bug where the color selection actions would color one more character than they needed to. Also fixes a bug where if mark mode was used to create the selection, a dangling y-beam would be left over after executing the action.   ## References and Relevant Issues Regressed in #18106 ## Detailed Description of the Pull Request / Additional comments - `TextBuffer::SpanLength` was only used once (in `Terminal::ColorSelection`). All it really did was call `Viewport::CompareInBounds`. So I deduplicated it. - Funny enough, the +1 added there was no longer correct because the incoming coordinates were switched from an inclusive range to an exclusive range. - To fix the dangling y-beam, I added a call to `_updateSelectionUI` in `ControlCore::ColorSelection`. This heuristic is used throughout the file for other selection-related functions. ## Validation Steps Performed ✅ color selection action highlights reference(s) to selected text ✅ color selection action highlights reference(s) to selected text when text is at right boundary ✅ dangling y-beam disappears after executing color selection actions Closes #18739
claunia added the pull-request label 2026-01-31 09:48:22 +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#31609