-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Terminal breaks copied text at window line wraps, even when the text has no new-line characters #5113
Comments
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": []
} |
I have the issue. Seems to have been introduced in v0.10.761.0. |
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. |
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. |
@zadjii-msft I can constantly reproduce it even when the viewport does not scroll. I found it's related to this: terminal/src/buffer/out/textBuffer.cpp Line 1543 in d47da2d
If I remove this mechanism, the copied text will not have extra new-lines. |
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. |
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 you're in luck because I'm working on this pretty aggressively over in #5181 |
As a workaround for now, resize the terminal window (enlarge or shrink) and try to copy&paste it again. It works for me. |
Now that the Terminal is doing a better job of actually marking which lines were and were not wrapped, we're not always copying lines as "wrapped" when they should be. We're more correctly marking lines as not wrapped, when previously we'd leave them marked wrapped. The real problem is here in the `ScrollFrame` method - we'd manually newline the cursor to make the terminal's viewport shift down to a new line. If we had to scroll the viewport for a _wrapped_ line, this would cause the Terminal to mark that line as broken, because conpty would emit an extra `\n` that didn't actually exist. This more correctly implements `ScrollFrame`. Now, well move where we "thought" the cursor was, so when we get to the next `PaintBufferLine`, if the cursor needs to newline for the next line, it'll newline, but if we're in the middle of a wrapped line, we'll just keep printing the wrapped line. A couple follow up bugs were found to be caused by the same bad logic. See #5039 and #5161 for more details on the investigations there. ## References * #4741 RwR, which probably made this worse * #5122, which I branched off of * #1245, #357 - a pair of other conpty wrapped lines bugs * #5228 - A followup issue for this PR ## PR Checklist * [x] Closes #5113 * [x] Closes #5180 (by fixing DECRST 25) * [x] Closes #5039 * [x] Closes #5161 (by ensuring we only `removeSpaces` on the actual bottom line) * [x] I work here * [x] Tests added/passed * [n/a] Requires documentation to be updated ## Validation Steps Performed * Checked the cases from #1245, #357 to validate that they still work * Added more and more tests for these scenarios, and then I added MORE tests * The entire team played with this in selfhost builds
🎉This issue was addressed in #5181, which has now been successfully released as Handy links: |
Does anyone know what's needed to get this into Cygwin? |
This is still broken in "1.0.1811.0". |
Still broken in Cygwin too fwiw. |
@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! |
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 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. |
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
C:\Windows\System32\WindowsCodecsRaw.txt
type C:\Windows\System32\WindowsCodecsRaw.txt
Expected and actual behavior
Expected: the text is all on one line.
Actual: the text is split into multiple lines.
The text was updated successfully, but these errors were encountered: