Terminal breaks copied text at window line wraps, even when the text has no new-line characters #7142

Closed
opened 2026-01-31 00:56:14 +00:00 by claunia · 17 comments
Owner

Originally created by @metathinker on GitHub (Mar 25, 2020).

Originally assigned to: @zadjii-msft on GitHub.

I recall this was working in older versions of Terminal and in Windows' copy of the console window, but it seems to have broken more recently.

Environment

Windows build number: 18363.720 (Windows 10 ver. 1909 with update KB4551762)
Windows Terminal version: 0.10.781.0

Steps to reproduce

  1. Open this file in an editor: C:\Windows\System32\WindowsCodecsRaw.txt
  2. Notice that the last line of the file "THE SOFTWARE IS PROVIDED".... is over 500 characters long.
  3. Open Terminal to the Command Prompt or PowerShell, then run:
    type C:\Windows\System32\WindowsCodecsRaw.txt
  4. Drag to select text from multiple in-window lines of the last line of the file, then right-click to copy.
  5. Paste the clipping into a new file in Notepad.

Expected and actual behavior

Expected: the text is all on one line.
Actual: the text is split into multiple lines.

Originally created by @metathinker on GitHub (Mar 25, 2020). Originally assigned to: @zadjii-msft on GitHub. I recall this was working in older versions of Terminal and in Windows' copy of the console window, but it seems to have broken more recently. ### Environment **Windows build number:** 18363.720 (Windows 10 ver. 1909 with update [KB4551762](https://support.microsoft.com/en-us/help/4551762)) **Windows Terminal version:** 0.10.781.0 ### Steps to reproduce 1. Open this file in an editor: `C:\Windows\System32\WindowsCodecsRaw.txt` 1. Notice that the last line of the file "THE SOFTWARE IS PROVIDED".... is over 500 characters long. 1. Open Terminal to the Command Prompt or PowerShell, then run: `type C:\Windows\System32\WindowsCodecsRaw.txt` 1. Drag to select text from multiple in-window lines of the last line of the file, then right-click to copy. 1. Paste the clipping into a new file in Notepad. ### Expected and actual behavior Expected: the text is all on one line. Actual: the text is split into multiple lines.
Author
Owner

@metathinker commented on GitHub (Mar 25, 2020):

Here's my profiles.json file in case that matters, though I can't see anything that stands out:

{
  "$schema": "https://aka.ms/terminal-profiles-schema",
  "defaultProfile": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
  "initialCols": 120,
  "initialRows": 40,
  "profiles": {
    "defaults": {
      "fontFace": "Consolas",
      "fontSize": 11,
      "historySize": 9999
    },
    "list": [
      {
        "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
        "name": "Command Prompt",
        "commandline": "%comspec%",
        "startingDirectory": "C:\\Windows\\System32",
        "hidden": false
      },
      {
        "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
        "name": "Windows PowerShell",
        "commandline": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
        "startingDirectory": "C:\\Windows\\System32",
        "hidden": false
      },
      {
        "guid": "{c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40}",
        "hidden": false,
        "name": "Ubuntu-18.04",
        "source": "Windows.Terminal.Wsl"
      },
      {
        "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
        "hidden": false,
        "name": "Azure Cloud Shell",
        "source": "Windows.Terminal.Azure"
      }
    ]
  },
  "schemes": [],
  "keybindings": []
}
@metathinker commented on GitHub (Mar 25, 2020): Here's my profiles.json file in case that matters, though I can't see anything that stands out: ```javascript { "$schema": "https://aka.ms/terminal-profiles-schema", "defaultProfile": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}", "initialCols": 120, "initialRows": 40, "profiles": { "defaults": { "fontFace": "Consolas", "fontSize": 11, "historySize": 9999 }, "list": [ { "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}", "name": "Command Prompt", "commandline": "%comspec%", "startingDirectory": "C:\\Windows\\System32", "hidden": false }, { "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", "name": "Windows PowerShell", "commandline": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "startingDirectory": "C:\\Windows\\System32", "hidden": false }, { "guid": "{c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40}", "hidden": false, "name": "Ubuntu-18.04", "source": "Windows.Terminal.Wsl" }, { "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}", "hidden": false, "name": "Azure Cloud Shell", "source": "Windows.Terminal.Azure" } ] }, "schemes": [], "keybindings": [] } ```
Author
Owner

@mg-christian-esser commented on GitHub (Mar 25, 2020):

I have the issue. Seems to have been introduced in v0.10.761.0.

@mg-christian-esser commented on GitHub (Mar 25, 2020): I have the issue. Seems to have been introduced in v0.10.761.0.
Author
Owner

@zadjii-msft commented on GitHub (Mar 25, 2020):

Okay so we’ve been seeing various reports of this in the most recent build, despite doing some work to specifically handle this better.

Turns out, it’ll only happen when it causes the viewport to scroll – like when you’re emitting text at the bottom of the window. This explains why it seems like sometimes it works fine and other times it doesn’t.

Now that we’ve got a consistent repro, it should make debugging much easier.

@zadjii-msft commented on GitHub (Mar 25, 2020): Okay so we’ve been seeing various reports of this in the most recent build, despite doing some work to specifically handle this better. Turns out, it’ll only happen when it causes the viewport to scroll – like when you’re emitting text at the bottom of the window. This explains why it seems like sometimes it works fine and other times it doesn’t. Now that we’ve got a consistent repro, it should make debugging _much_ easier.
Author
Owner

@metathinker commented on GitHub (Mar 25, 2020):

Turns out, it’ll only happen when it causes the viewport to scroll – like when you’re emitting text at the bottom of the window.

I'm not sure that's quite right? I just tried starting Terminal with the profiles.json above and typing out the file, which doesn't cause a scroll of the displayed area as far as I can see. After copying the first 3 displayed lines of the "THE SOFTWARE" line of text (up to "OR ANY DAMAGES W"), I get 2 lines in Notepad.

@metathinker commented on GitHub (Mar 25, 2020): > Turns out, it’ll only happen when it causes the viewport to scroll – like when you’re emitting text at the bottom of the window. I'm not sure that's quite right? I just tried starting Terminal with the profiles.json above and typing out the file, which doesn't cause a scroll of the displayed area as far as I can see. After copying the first 3 displayed lines of the "THE SOFTWARE" line of text (up to "OR ANY DAMAGES W"), I get 2 lines in Notepad.
Author
Owner

@zadjii-msft commented on GitHub (Mar 25, 2020):

I mean, here's what I'm seeing when I do type C:\Windows\System32\WindowsCodecsRaw.txt with a fresh WT:
image
(note the line numbers in Sublime, behind WT)

Then, performing it a second time, which causes the scrolling:
image

@zadjii-msft commented on GitHub (Mar 25, 2020): I mean, here's what I'm seeing when I do `type C:\Windows\System32\WindowsCodecsRaw.txt` with a fresh WT: ![image](https://user-images.githubusercontent.com/18356694/77563629-83de8b00-6e8f-11ea-954a-667de35200b0.png) (note the line numbers in Sublime, behind WT) Then, performing it a second time, which causes the scrolling: ![image](https://user-images.githubusercontent.com/18356694/77563686-99ec4b80-6e8f-11ea-8f61-c9ba055272ac.png)
Author
Owner

@skyline75489 commented on GitHub (Mar 26, 2020):

@zadjii-msft I can constantly reproduce it even when the viewport does not scroll. I found it's related to this:

d47da2d617/src/buffer/out/textBuffer.cpp (L1543)

If I remove this mechanism, the copied text will not have extra new-lines.

@skyline75489 commented on GitHub (Mar 26, 2020): @zadjii-msft I can constantly reproduce it even when the viewport does not scroll. I found it's related to this: https://github.com/microsoft/terminal/blob/d47da2d617dbda3a46a1a052122536eca123b722/src/buffer/out/textBuffer.cpp#L1543 If I remove this mechanism, the copied text will not have extra new-lines.
Author
Owner

@ghost commented on GitHub (Apr 1, 2020):

For me as an Admin and DevOps this is a major issue - for example: ssh pubkeys are breaking when being copied and pasted.

For anyone who need to downgrade due to this, I can recommend to do this via choco like this:

choco list microsoft-windows-terminal --all
choco uninstall microsoft-windows-terminal
choco install microsoft-windows-terminal --version 0.10.761.0

Don't forget to store your current profile.json somewhere - when you uninstall the Terminal app, the profile will be resetted to defaults!

Hope this helps.

@ghost commented on GitHub (Apr 1, 2020): For me as an Admin and DevOps this is a major issue - for example: ssh pubkeys are breaking when being copied and pasted. For anyone who need to downgrade due to this, I can recommend to do this via choco like this: ``` choco list microsoft-windows-terminal --all choco uninstall microsoft-windows-terminal choco install microsoft-windows-terminal --version 0.10.761.0 ``` Don't forget to store your current profile.json somewhere - when you uninstall the Terminal app, the profile will be resetted to defaults! Hope this helps.
Author
Owner

@paul-michalik commented on GitHub (Apr 7, 2020):

@hirschnase

For me as an Admin and DevOps this is a major issue - for example: ssh pubkeys are breaking when being copied and pasted.
For anyone who need to downgrade due to this, I can recommend to do this via choco like this:
choco list microsoft-windows-terminal --all
choco uninstall microsoft-windows-terminal
choco install microsoft-windows-terminal --version 0.10.761.0

The version 0.10.761.0 exhibits the same behavior. You need to go to 0.9.433.0. And even there, the problem remains when you copy-paste between different shells. For example, copy from CMD and paste into Git/bin/bash.exe shell in a different tab works while the same operation in opposite direction does not work. This seems to be a problem of the underlying shells though... Would be great if this would be handled by wt.exe!

@paul-michalik commented on GitHub (Apr 7, 2020): @hirschnase > For me as an Admin and DevOps this is a major issue - for example: ssh pubkeys are breaking when being copied and pasted. > For anyone who need to downgrade due to this, I can recommend to do this via choco like this: > choco list microsoft-windows-terminal --all > choco uninstall microsoft-windows-terminal > choco install microsoft-windows-terminal --version 0.10.761.0 The version 0.10.761.0 exhibits the same behavior. You need to go to 0.9.433.0. And even there, the problem remains when you copy-paste between different shells. For example, copy from CMD and paste into Git/bin/bash.exe shell in a different tab works while the same operation in opposite direction does not work. This seems to be a problem of the underlying shells though... Would be great if this would be handled by wt.exe!
Author
Owner

@zadjii-msft commented on GitHub (Apr 7, 2020):

@paul-michalik you're in luck because I'm working on this pretty aggressively over in #5181

@zadjii-msft commented on GitHub (Apr 7, 2020): @paul-michalik you're in luck because I'm working on this pretty aggressively over in #5181
Author
Owner

@hmageste commented on GitHub (Apr 7, 2020):

As a workaround for now, resize the terminal window (enlarge or shrink) and try to copy&paste it again. It works for me.

@hmageste commented on GitHub (Apr 7, 2020): As a workaround for now, resize the terminal window (enlarge or shrink) and try to copy&paste it again. It works for me.
Author
Owner

@ghost commented on GitHub (Apr 22, 2020):

:tada:This issue was addressed in #5181, which has now been successfully released as Windows Terminal Preview v0.11.1121.0.🎉

Handy links:

@ghost commented on GitHub (Apr 22, 2020): :tada:This issue was addressed in #5181, which has now been successfully released as `Windows Terminal Preview v0.11.1121.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v0.11.1121.0) * [Store Download](https://www.microsoft.com/store/apps/9n0dx20hk701?cid=storebadge&ocid=badge)
Author
Owner

@ElvenSpellmaker commented on GitHub (Apr 23, 2020):

Does anyone know what's needed to get this into Cygwin?

@ElvenSpellmaker commented on GitHub (Apr 23, 2020): Does anyone know what's needed to get this into Cygwin?
Author
Owner

@ghost commented on GitHub (Jul 13, 2020):

This is still broken in "1.0.1811.0".

@ghost commented on GitHub (Jul 13, 2020): This is still broken in "1.0.1811.0".
Author
Owner

@ElvenSpellmaker commented on GitHub (Jul 13, 2020):

Still broken in Cygwin too fwiw.

@ElvenSpellmaker commented on GitHub (Jul 13, 2020): Still broken in Cygwin too fwiw.
Author
Owner

@zadjii-msft commented on GitHub (Jul 13, 2020):

@nvonwolf This was a pretty specific scenario that should have been fixed by #5181. If you're still seeing this behavior, could you file a new issue with exact repro steps, so we could track the new regression? Thanks!

@zadjii-msft commented on GitHub (Jul 13, 2020): @nvonwolf This was a pretty specific scenario that _should_ have been fixed by #5181. If you're still seeing this behavior, could you file a new issue with exact repro steps, so we could track the new regression? Thanks!
Author
Owner

@lindhe commented on GitHub (Oct 11, 2023):

I'm at 1.17.11461.0 and still have this issue. Not with scrolling, but always. :(

Anything I can do about it? Should I open a new issue or stick to this one?

@lindhe commented on GitHub (Oct 11, 2023): I'm at 1.17.11461.0 and still have this issue. Not with scrolling, but always. :( Anything I can do about it? Should I open a new issue or stick to this one?
Author
Owner

@zadjii-msft commented on GitHub (Oct 11, 2023):

@lindhe I'd recommend filing a new issue, with more details about your setup. Also, I'd recommend trying out Terminal Preview - I'm pretty sure there were some fixes in the 1.18/1.19 timeframe that might have helped with some scenarios around this topic.

@zadjii-msft commented on GitHub (Oct 11, 2023): @lindhe I'd recommend filing a new issue, with more details about your setup. Also, I'd recommend trying out [Terminal Preview](https://aka.ms/terminal-preview) - I'm pretty sure there were some fixes in the 1.18/1.19 timeframe that might have helped with some scenarios around this topic.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#7142