[PR #1094] [CLOSED] Convert paste line endings #24476

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/1094
Author: @d-bingham
Created: 6/1/2019
Status: Closed

Base: masterHead: convert-paste-line-endings


📝 Commits (7)

📊 Changes

7 files changed (+65 additions, -1 deletions)

View changed files

📝 src/cascadia/TerminalApp/Profile.cpp (+17 -0)
📝 src/cascadia/TerminalApp/Profile.h (+1 -0)
📝 src/cascadia/TerminalControl/TermControl.cpp (+31 -1)
📝 src/cascadia/TerminalControl/TermControl.h (+1 -0)
📝 src/cascadia/TerminalSettings/IControlSettings.idl (+1 -0)
📝 src/cascadia/TerminalSettings/TerminalSettings.cpp (+11 -0)
📝 src/cascadia/TerminalSettings/terminalsettings.h (+3 -0)

📄 Description

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:


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/1094 **Author:** [@d-bingham](https://github.com/d-bingham) **Created:** 6/1/2019 **Status:** ❌ Closed **Base:** `master` ← **Head:** `convert-paste-line-endings` --- ### 📝 Commits (7) - [`a728fd7`](https://github.com/microsoft/terminal/commit/a728fd7230d335788f22e1dfc4d5e826c4a0244e) Add option to convert line endings (from CRLF to LF) on paste. - [`bd1b1b2`](https://github.com/microsoft/terminal/commit/bd1b1b2c104efcc52bb8a32431816e693ec1c58f) Fixing tabs on .idl files. - [`3cf80f4`](https://github.com/microsoft/terminal/commit/3cf80f4b8c8f09616c51a8d4f07d5dbfdced47ea) Sending CR instead of LF. - [`b3e26cf`](https://github.com/microsoft/terminal/commit/b3e26cf5f746a9c7434077916c8ac59fecf510e6) Synchronizing fork - [`6feeb75`](https://github.com/microsoft/terminal/commit/6feeb758fef8d08c439da8d336a49579a9d04401) Merge branch 'convert-paste-line-endings' of https://github.com/d-bingham/terminal into convert-paste-line-endings - [`eeb7c8e`](https://github.com/microsoft/terminal/commit/eeb7c8e2d98269b5bc8c553f3fbc8012dea32685) Merge remote-tracking branch 'upstream/master' into convert-paste-line-endings - [`4cc1db4`](https://github.com/microsoft/terminal/commit/4cc1db4a04231f9e7ede5b014d2af78247eae4dd) Fixing formatting issues ### 📊 Changes **7 files changed** (+65 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalApp/Profile.cpp` (+17 -0) 📝 `src/cascadia/TerminalApp/Profile.h` (+1 -0) 📝 `src/cascadia/TerminalControl/TermControl.cpp` (+31 -1) 📝 `src/cascadia/TerminalControl/TermControl.h` (+1 -0) 📝 `src/cascadia/TerminalSettings/IControlSettings.idl` (+1 -0) 📝 `src/cascadia/TerminalSettings/TerminalSettings.cpp` (+11 -0) 📝 `src/cascadia/TerminalSettings/terminalsettings.h` (+3 -0) </details> ### 📄 Description <!-- 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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:03:31 +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#24476