[PR #4578] Abstract GetTextForClipboard() for UIA #25850

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

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

State: closed
Merged: Yes


Summary of the Pull Request

GetTextForClipboard already exists in the TextBuffer. It makes sense to use that for UIA as well. This changes the behavior or GetText() such that it does not remove leading/trailing whitespace anymore. That is more of an expected behavior.

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 😀

PR Checklist

  • CLA signed.
  • Tests added/passed

Detailed Description of the Pull Request / Additional comments

  • TextBuffer::GetTextForClipboard() --> GetText()
  • TextBuffer::GetText() no longer requires GetForegroundColor/GetBackgroundColor. If either of these are not defined, we return a TextAndColor with only the text field populated.
  • renamed a few parameters for copying text to the clipboard for clarity
  • Updated UiaTextRange::GetText() to use TextBuffer::GetText()
    • ⚠ NOTE: This will conflict with PR #4495 but I'm ready.

Validation Steps Performed

Manual tests for UIA using accessibility insights and Windows Terminal's copy action (w/ and w/out shift)

Added tests as well.

**Original Pull Request:** https://github.com/microsoft/terminal/pull/4578 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request `GetTextForClipboard` already exists in the TextBuffer. It makes sense to use that for UIA as well. This changes the behavior or `GetText()` such that it does not remove leading/trailing whitespace anymore. That is more of an expected behavior. ## 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 😀 ## PR Checklist * [X] CLA signed. * [X] Tests added/passed ## Detailed Description of the Pull Request / Additional comments - `TextBuffer::GetTextForClipboard()` --> `GetText()` - `TextBuffer::GetText()` no longer requires GetForegroundColor/GetBackgroundColor. If either of these are not defined, we return a `TextAndColor` with only the `text` field populated. - renamed a few parameters for copying text to the clipboard for clarity - Updated `UiaTextRange::GetText()` to use `TextBuffer::GetText()` - ⚠ NOTE: This will conflict with PR #4495 but I'm ready. ## Validation Steps Performed Manual tests for UIA using accessibility insights and Windows Terminal's copy action (w/ and w/out shift) Added tests as well.
claunia added the pull-request label 2026-01-31 09:12:13 +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#25850