[PR #8579] Fix Copy to Clipboard to preserve visual structure of block selection #27241

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

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

State: closed
Merged: Yes


There are two issue with copy to clipboard when block is selected:

  • We don't add new lines for lines that were wrapped
  • We remove trailing whitespaces which is not intuitive in block selection.

Fixed the copy logic to always add newlines and not to remove
whitespaces when block is selected.

Even if shift is pressed!

Detailed Description of the Pull Request / Additional comments

  • Added optional parameter to TextBuffer::GetText
    that allows to apply formatting (includeCRLF / trimming)
    to lines that were wrapped
  • Changed Terminal::RetrieveSelectedTextFromBuffer
    to apply the following parameters when block is selected:
    • includeCRLF = true
    • trimTrailingWhitespaces = false
    • apply the formatting above to all rows, including the ones
      that were wrapped

Validation Steps Performed

  • Manual tests for both block and standard selection
  • Copy with both right-click and command
  • Added UT

Closes #6740

**Original Pull Request:** https://github.com/microsoft/terminal/pull/8579 **State:** closed **Merged:** Yes --- There are two issue with copy to clipboard when block is selected: * We don't add new lines for lines that were wrapped * We remove trailing whitespaces which is not intuitive in block selection. Fixed the copy logic to always add newlines and not to remove whitespaces when block is selected. Even if shift is pressed! ## Detailed Description of the Pull Request / Additional comments * Added optional parameter to `TextBuffer::GetText` that allows to apply formatting (includeCRLF / trimming) to lines that were wrapped * Changed `Terminal::RetrieveSelectedTextFromBuffer` to apply the following parameters when block is selected: * includeCRLF = true * trimTrailingWhitespaces = false * apply the formatting above to all rows, including the ones that were wrapped ## Validation Steps Performed * Manual tests for both block and standard selection * Copy with both right-click and command * Added UT Closes #6740
claunia added the pull-request label 2026-01-31 09:20:49 +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#27241