terminal
terminal copied to clipboard
VtEngine: Console-style (undelayed) line wraps results in \r\n
Windows Terminal version
1.16.230126001
Windows build number
No response
Other Software
No response
Steps to reproduce
- Use cmd.exe
- Scroll at least 1 viewport down (hold Enter or Ctrl+C, etc.)
- Type text until it line wraps
- Copy the prompt to your clipboard
Expected Behavior
Clipboard contains 1 line of text without line wraps.
Actual Behavior
The clipboard is line wrapped at the right margin.
XtermEngine::_MoveCursor is called 3 times during the forced line wrap. When I type a single "a" at the end of the prompt, this results in 3 cursor movement sequences in total and the character being printed twice:
a\r\n\x1b[23;80Ha\r\n
I'm setting this to P2 because this bug has probably existed since the beginning. There might be a duplicate already.
I suspect that this may actually have "worked" in the past, because of the exact-wrap bug (#3088). If your output has wrapped in a legacy console app, that would assumedly mean you had written something in the last column of the line. And if I remember correctly, that used to be enough for the resize algorithm to consider the line as being wrapped. I'm not sure about copy-to-clipboard though.
As for fixing it, I didn't think there was an easy way to reproduce legacy-style wrapping on a VT terminal. To trigger a wrap, you've got to write something past the end end of the line, which potentially means you're overwriting whatever is on the next line. In our current conpty implementation we could at least lookup the character on the next line, and write that out, but that seems horribly hacky, and would never work in a full pass-through mode.
I don't know if maybe you have a better plan than that.