terminal: Terminal breaks copied text at window line wraps, even when the text has no new-line characters
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
- Open this file in an editor:
C:\Windows\System32\WindowsCodecsRaw.txt
- Notice that the last line of the file “THE SOFTWARE IS PROVIDED”… is over 500 characters long.
- Open Terminal to the Command Prompt or PowerShell, then run:
type C:\Windows\System32\WindowsCodecsRaw.txt
- Drag to select text from multiple in-window lines of the last line of the file, then right-click to copy.
- 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.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 15
- Comments: 17 (7 by maintainers)
@paul-michalik you’re in luck because I’m working on this pretty aggressively over in #5181
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:
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.
@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.
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.
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.
🎉This issue was addressed in #5181, which has now been successfully released as
Windows Terminal Preview v0.11.1121.0
.🎉Handy links:
@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.
This is still broken in “1.0.1811.0”.
As a workaround for now, resize the terminal window (enlarge or shrink) and try to copy&paste it again. It works for me.