[PR #4560] Move rect expansion to textbuffer; refactor selection code #25840

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

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

State: closed
Merged: Yes


  • When performing chunk selection, the expansion now occurs at the time
    of the selection, not the rendering of the selection
  • GetSelectionRects() was moved to the TextBuffer and is now shared
    between ConHost and Windows Terminal
  • Some of the selection variables were renamed for clarity
  • Selection COORDs are now in the Text Buffer coordinate space
  • Fixes an issue with Shift+Click after performing a Multi-Click
    Selection

References

This also contributes to...

  • #4509: UIA Box Selection
  • #2447: UIA Signaling for Selection
  • #1354: UIA support for Wide Glyphs

Now that the expansion occurs at before render-time, the selection
anchors are an accurate representation of what is selected. We just need
to move GetText to the TextBuffer. Then we can have those three
issues just rely on code from the text buffer. This also means ConHost
gets some of this stuff for free 😀

TextBuffer

  • GetTextRects is the abstracted form of GetSelectionRects
  • _ExpandTextRow is still needed to handle wide glyphs properly

Terminal

  • Rename...
    • _boxSelection --> _blockSelection for consistency with ConHost
    • _selectionAnchor --> _selectionStart for consistency with UIA
    • _endSelectionPosition --> _selectionEnd for consistency with
      UIA
  • Selection anchors are in Text Buffer coordinates now
  • Really rely on SetSelectionEnd to accomplish appropriate chunk
    selection and shift+click actions

Validation Steps Performed

  • Shift+Click
  • Multi-Click --> Shift+Click
  • Chunk Selection at...
    • top of buffer
    • bottom of buffer
    • random region in scrollback

Closes #4465
Closes #4547

**Original Pull Request:** https://github.com/microsoft/terminal/pull/4560 **State:** closed **Merged:** Yes --- - When performing chunk selection, the expansion now occurs at the time of the selection, not the rendering of the selection - `GetSelectionRects()` was moved to the `TextBuffer` and is now shared between ConHost and Windows Terminal - Some of the selection variables were renamed for clarity - Selection COORDs are now in the Text Buffer coordinate space - Fixes an issue with Shift+Click after performing a Multi-Click Selection ## References This also contributes to... - #4509: UIA Box Selection - #2447: UIA Signaling for Selection - #1354: UIA support for Wide Glyphs Now that the expansion occurs at before render-time, the selection anchors are an accurate representation of what is selected. We just need to move `GetText` to the `TextBuffer`. Then we can have those three issues just rely on code from the text buffer. This also means ConHost gets some of this stuff for free 😀 ### TextBuffer - `GetTextRects` is the abstracted form of `GetSelectionRects` - `_ExpandTextRow` is still needed to handle wide glyphs properly ### Terminal - Rename... - `_boxSelection` --> `_blockSelection` for consistency with ConHost - `_selectionAnchor` --> `_selectionStart` for consistency with UIA - `_endSelectionPosition` --> `_selectionEnd` for consistency with UIA - Selection anchors are in Text Buffer coordinates now - Really rely on `SetSelectionEnd` to accomplish appropriate chunk selection and shift+click actions ## Validation Steps Performed - Shift+Click - Multi-Click --> Shift+Click - Chunk Selection at... - top of buffer - bottom of buffer - random region in scrollback Closes #4465 Closes #4547
claunia added the pull-request label 2026-01-31 09:12:10 +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#25840