[PR #1094] Convert paste line endings #24481

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

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

State: closed
Merged: No


Summary of the Pull Request

Implements line-ending conversion for pasting. Specifically by introducing a new option -- convertPasteLineEndings (optional, defaults to false) -- which, when set, causes pastes from the clipboard to have CRLF pairs converted to LFs.

See here: (Top copy/paste is prior behavior or convertPasteLineEndings set to false; bottom is convertPasteLineEndings set to true; this is Terminal running WSL bash):

image

References

PR Checklist

Detailed Description of the Pull Request / Additional comments

The new option, convertPasteLineEndings does what it says -- replacing Windows-space CRLF pairs with Unix-space LFs in text pasted to the console. This option applies to both the keyboard-shortcut paste and the right-click paste. Without this most multiline text pasted into Terminal will be "double-spaced" due to the Windows-style CRLF pairs. Furthermore, any multiline text copied from Terminal (in trim whitespace mode) generates CRLF pairs, which guarantees double-spacing when copying from a WSL Terminal session.

Changes:

  • Added TermControl::_SendPastedTextToConnection which adds a pre-processing layer on top of _SendInputToConnection to allow line-ending conversion
  • Various code in Profile/TerminalSettings to support the new option "convertPasteLineEndings" (optional, defaults to false)

Notes:

**Original Pull Request:** https://github.com/microsoft/terminal/pull/1094 **State:** closed **Merged:** No --- <!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request Implements line-ending conversion for pasting. Specifically by introducing a new option -- convertPasteLineEndings (optional, defaults to false) -- which, when set, causes pastes from the clipboard to have CRLF pairs converted to LFs. See here: (Top copy/paste is prior behavior or convertPasteLineEndings set to false; bottom is convertPasteLineEndings set to true; this is Terminal running WSL bash): ![image](https://user-images.githubusercontent.com/26487560/58742979-47690c80-83ef-11e9-9f34-2d5a0fde1bc7.png) <!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> ## References <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [x] Closes #1091 * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [ ] Tests added/passed * [x] Requires documentation to be updated -- adds new option * [x] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #1072, #1091 <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments The new option, _convertPasteLineEndings_ does what it says -- replacing Windows-space CRLF pairs with Unix-space LFs in text pasted to the console. This option applies to both the keyboard-shortcut paste and the right-click paste. Without this most multiline text pasted into Terminal will be "double-spaced" due to the Windows-style CRLF pairs. Furthermore, any multiline text copied from Terminal (in trim whitespace mode) generates CRLF pairs, which guarantees double-spacing when copying from a WSL Terminal session. Changes: - Added TermControl::_SendPastedTextToConnection which adds a pre-processing layer on top of _SendInputToConnection to allow line-ending conversion - Various code in Profile/TerminalSettings to support the new option "convertPasteLineEndings" (optional, defaults to false) Notes: - Split from #1072
claunia added the pull-request label 2026-01-31 09:03:33 +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#24481