-
-
Notifications
You must be signed in to change notification settings - Fork 786
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
Newlines added to text copied from Windows full-screen applications #3177
Comments
Take a look at https://wezfurlong.org/wezterm/config/lua/config/canonicalize_pasted_newlines.html in particular, the last couple of paragraphs |
That's a separate issue. I tried different settings for This issue is about copying to clipboard, not about pasting from it. That's why I'm using notepad to demonstrate the issue. Also, I don't care much about copying and pasting multi-line text. I want to copy a single word or part of a single string and paste it. I get several newlines after that, which is unexpected. That's especially bad when copying a command that I want to edit, but it runs as is. |
@wangvisual: yes, it looks like the same issue. It's not clear from that ticket is the issue is with copying or pasting. In my case, the issue is with copying, I can see newlines when pasting in Notepad. The vi bracketed mode should be irrelevant, as it affects pasting only, not copying. |
The issue is "fixed" by commenting out this code in
Unfortunately, it breaks copying of multi-line selections as they are copied without newlines. But it's very rare that I need that functionality. I copy text that fits one line most of the time. At least we know where the newlines are coming from, so it could be a good starting point for the correct fix. |
Here's my progress so far. |
The behavior of impl_get_logical_lines_via_get_lines() was inconsistent when all physical lines appeared to be one wrapped logical line. The combined logical line would be appended to the result if and only if it exceeded MAX_LOGICAL_LINE_LEN (1024) characters. Having an extra logical line in the result would lead to an extra newline being added to the text copied to clipboard. Fixes wez#3177.
Really, this is adjusting the logical line breaking behavior, or the lack thereof. The situation is this: conpty can decided to reinterpret and flush large sections of its buffer as a continuous stream of unbroken characters with no breaks when it repaints the full screen. When we receive such an update, we see it as one long logical line, and when we subsequently select multiple lines we can run into the maximum logical line length and insert invalid synthetic line breaks into the data that we send to the clipboard. This commit adjusts the wrapping logic at the time that we receive the text so that we don't tag the line as a logical line continuation if: * The alt screen is active. Full screen apps will re-render on resize anyway, and we don't reflow long lines on resize either for the same reasons * If we are talking to ConPTY: * If the last character in the line is not alphanumeric or punctuation (in other words: it doesn't look plausibly like text that should be a line continuation). refs: #3278 refs: #3177
is there more that needs to be done here? |
No, it's good now. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
What Operating System(s) are you seeing this problem on?
Windows
Which Wayland compositor or X11 Window manager(s) are you using?
No response
WezTerm version
wezterm 20230226-223328-0ac1cbc4
Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?
Yes, and I updated the version box above to show the version of the nightly that I tried
Describe the bug
When text is selected by mouse in certain Windows programs (Far Manager, Midnight Commander for Windows, vi from OpenWatcom 1.9), sometimes it is copied to the clipboard with extra newlines at the end. The way to trigger the issue is to select multi-line text with mouse. After that, even single words selected by mouse have newlines at the end.
I know that the newlines are in the clipboard by pasting text in another program such as Notepad.
I've seen up to 30 newlines appended, but sometimes it's just one or two. After selecting several short single-line snippets, the issue goes away.
Some full-screen Windows programs are not affected. For instance, vim from msys2 doesn't appear to be affected. Programs run remotely over SSH are not affected either.
To Reproduce
Install OpenWatcom 1.9
Start wezterm
Run OpenWatcom vi:
C:\WATCOM\binnt\vi.exe
Select several lines by mouse
Select one word e.g.
no_name
by mouseOpen notepad
Paste
Most of the time, at least one newline would appear after the
no_name
Configuration
No config
Expected Behavior
no_name
is pasted without any newlines at the endLogs
Anything else?
My guess is that there is some Windows-specific code for adding newlines to the text added to the clipboard (perhaps for certain kind of Windows programs), and the data used by that code is not cleared when a new text is selected.
The text was updated successfully, but these errors were encountered: