Skip to content
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

Make sure WT can copy wrapped lines as a single line #3367

Closed
angelog0 opened this issue Oct 29, 2019 · 19 comments · Fixed by #4415
Closed

Make sure WT can copy wrapped lines as a single line #3367

angelog0 opened this issue Oct 29, 2019 · 19 comments · Fixed by #4415
Labels
Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Issue-Task It's a feature request, but it doesn't really need a major design. Priority-2 A description (P2) Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.
Milestone

Comments

@angelog0
Copy link

I created this profile (since WT 0.5),

{
            "guid": "{9c173dff-f524-43df-b40e-29953998c744}",
            "name": "MSYS2 Terminal",
            "commandline": "cmd.exe /c \"set MSYSTEM=MSYS&& set MSYS=winsymlinks:nativestrict&& C:/msys64/usr/bin/bash.exe --login\"",
            "hidden": false,
            "startingDirectory": "C:/msys64/home/user",
            "closeOnExit": true,
            "colorScheme": "MSYS2-Theme",
            "cursorColor": "#FD9D4F",
            "cursorShape": "filledBox",
            "fontFace": "Cascadia Code",
            "fontSize": 11,
            "historySize": 9001,
            "icon": "C:/msys64/msys2.ico",
            "padding": "8, 8, 8, 8",
            "snapOnInput": true// ,
            // "useAcrylic": true,
            // "acrylicOpacity": 0.75
        }

and noticed that when I paste a long line as in
long_line it works wrong

$ ls -lrt /usr/lib/gcc/ /usr/lib/gcc/ /usr/lib/gcc/ /usr/lib/gcc/ /usr/lib/gcc/ /usr/lib/gcc/ /usr/lib/gcc/ /usr/lib/gc
ls: impossibile accedere a '/usr/lib/gc': No such file or directory
[...]
$ c/ /usr/lib/gcc/ /usr/lib/gcc/

This does not occur in Ubuntu or DOS or PoweShell profiles.

In short, it does not like the end of line when using MSYS2 profile. Maybe you have some suggestions...

(BTW, I copied that line dragging the mouse and pasting with right click, as usually one have to do in WT)

The system is W10 Pro 64 10.0.18362.449.

@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Oct 29, 2019
@DHowett-MSFT
Copy link
Contributor

This is due to a lack of wrapping copy, not paste.

@DHowett-MSFT DHowett-MSFT added Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal. labels Oct 29, 2019
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Oct 29, 2019
@DHowett-MSFT DHowett-MSFT changed the title Still issue pasting long lines in MSYS2 profile Make sure WT can copy wrapped lines as a single line Oct 29, 2019
@DHowett-MSFT DHowett-MSFT removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Oct 29, 2019
@DHowett-MSFT
Copy link
Contributor

Broadly, this is related to #780 and #2089.

@Biswa96
Copy link

Biswa96 commented Oct 30, 2019

Does this happen in latest cygwin also?

@angelog0
Copy link
Author

@Biswa96, I do not use cygwin since 2014. The basic DLL in MSYS2 is the same version:

$ pacman -Ss msys2 | grep runtime
msys/msys2-runtime 3.0.7-6 (base) [installato]
msys/msys2-runtime-devel 3.0.7-6 (msys2-devel) [installato]

BTW, in MinTTY-MSYS2 it works as expected, without problems (the same as in Ubuntu-WT or CMD-WT profiles).

See the MSYS2 profile I posted above, may be it need some adjustment? Some other environment variable or what else?

@Biswa96
Copy link

Biswa96 commented Oct 30, 2019

Try this "commandline": "C:\\msys64\\usr\\bin\\bash.exe -i -l".

@angelog0
Copy link
Author

No, it has the same issue. Beside this, I need to set those environment variables.. How with the command line you suggest?

@angelog0
Copy link
Author

angelog0 commented Oct 30, 2019

BTW, the default profile (defaults.json) sets

"initialCols": 120,

but in MSYS2 profile they, really, are 119. See
cl-width-MSYS2 while in Ubuntu profile, effectively, they are 120. See
cl-width-Ubuntu

I typed 34567890 and copy/pasted 1234567890 up to the second line. notice the bigger gap for MSYS2...

@fanvinga
Copy link

fanvinga commented Nov 4, 2019

This problem also exists for me. For me, the scenario that caused the issue was that I tried to copy the Dockerfile cross-line command to the Windows Terminal (WSL2), there would be extra blank lines, and bash would be recognized as a one-line command.

@angelog0
Copy link
Author

Same issues with WT 0.7...

@fanvinga
Copy link

A4FF48B2-B8EB-453F-A600-9F454C7ACF38
@angelog0 0.7.3291 seems to have solved the cross-row copy issue I complained about earlier

@angelog0
Copy link
Author

angelog0 commented Nov 29, 2019

The issue seems related to TERM variable.

When one starts MSYS2 with the launcher msys2.exe, TERM results equal to xterm. In WT it is set to cygwin.

Now if I use in the WT profile

"commandline": "cmd.exe /c \"set TERM=xterm&& set MSYSTEM=MSYS&& set MSYS=winsymlinks:nativestrict&& C:/msys64/usr/bin/bash.exe --login\""

the issue seems fixed and the line is 130 craracters long but Emacs in terminal (msys/emacs 26.3-1) has issues: its window displays garbage and the colors are not so good.

@Biswa96
Copy link

Biswa96 commented Nov 29, 2019

How about TERM=xterm-256color?

@angelog0
Copy link
Author

No, it is worse.

For completeness, I have attached the result with MinTTY-TERM=xterm, WT-TERM=xterm, WT-TERM=xterm-256color. emacs-WT.tar.gz

@angelog0
Copy link
Author

angelog0 commented Dec 7, 2019

For the sake of completeness, the issue is still active in the last 0.7.3382.0 WT release...

@DHowett-MSFT
Copy link
Contributor

@angelog0 thank you. Since this isn’t a bug and requires actual investment to make the line wrapping feature work, we aren’t likely to fix it accidentally. We will definitely close this workitem when we know it to be complete.

@ghost ghost added the In-PR This issue has a related PR label Jan 30, 2020
@ghost ghost closed this as completed in #4415 Feb 27, 2020
@ghost ghost added Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. and removed In-PR This issue has a related PR labels Feb 27, 2020
ghost pushed a commit that referenced this issue Feb 27, 2020
## Summary of the Pull Request

Changes how conpty emits text to preserve line-wrap state, and additionally adds rudimentary support to the Windows Terminal for wrapped lines.

## References

* Does _not_ fix (!) #3088, but that might be lower down in conhost. This makes wt behave like conhost, so at least there's that
* Still needs a proper deferred EOL wrap implementation in #780, which is left as a todo
* #4200 is the mega bucket with all this work
* MSFT:16485846 was the first attempt at this task, which caused the regression MSFT:18123777 so we backed it out.
* #4403 - I made sure this worked with that PR before I even sent #4403

## PR Checklist
* [x] Closes #405
* [x] Closes #3367 
* [x] I work here
* [x] Tests added/passed
* [n/a] Requires documentation to be updated

## Detailed Description of the Pull Request / Additional comments

I started with the following implementation:
When conpty is about to write the last column, note that we wrapped this line here. If the next character the vt renderer is told to paint get is supposed to be at the start of the following line, then we know that the previous line had wrapped, so we _won't_ emit the usual `\r\n` here, and we'll just continue emitting text.

However, this isn't _exactly_ right - if someone fills the row _exactly_ with text, the information that's available to the vt renderer isn't enough to know for sure if this line broke or not. It is possible for the client to write a full line of text, with a `\n` at the end, to manually break the line. So, I had to also add the `lineWrapped` param to the `IRenderEngine` interface, which is about half the files in this changelist.

## Validation Steps Performed
* Ran tests
* Checked how the Windows Terminal behaves with these changes
* Made sure that conhost/inception and gnome-terminal both act as you'd expect with wrapped lines from conpty
@angelog0
Copy link
Author

Sorry, you have closed this

@msftbot bot closed this in #4415 19 days ago

but ALL defects I flagged here and here

are present in Windows Terminal Preview 0.10.761.0.

Are you sure you have rightly test the fix before to establish the issue was fixed?

BTW, #4415 is also cited here...

@DHowett-MSFT
Copy link
Contributor

Okay: as far as I can tell, your shell is inserting a manual line break one character before the console would word-wrap. It's inserting a literal manual line break, so there's no hope that WT can recover from that.

If I emit the contents of a long text file to the screen, it writes all the way up to the right edge and copies out of WT as a single line.

image

If the application emits its own newline because it misunderstood the size of the screen, it writes all the way up to the newline and copies out of WT as two lines.

image

As long as they're doing that, by literally telling us to break the line, there isn't anything we can do to repair it.

We've fixed all other known cases of broken line wrap on copy/paste.

@angelog0
Copy link
Author

@DHowett-MSFT you are missing that only in WT that occurs. In MinTTY and other terminals copy/past of long lines works as expected. Admitting your conclusions would admit that WT is not usable as terminal with MSYS2 and friends. Maybe I will switch back to MinTTY because this is an issue tha causes many trouble to me.

@DHowett-MSFT
Copy link
Contributor

I can't help that msys has a special contract with MinTTY. If you do this in the traditional windows console, it has the same behavior. This is 100% an application bug.

image

Conhost has supported line wrapping for five years -- it also works for every other application that correctly prints to the edge of the screen. It might be time for MSYS to reconsider how it interacts with the console.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Issue-Task It's a feature request, but it doesn't really need a major design. Priority-2 A description (P2) Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants