microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
95.44k stars 8.3k forks source link

[Regressed in 19H1] When you copy text out of FAR manager, it gets line wrapped #7662

Open DHowett opened 4 years ago

DHowett commented 4 years ago

It appears that some time between RS5 and 19H1 we changed how line wrapping/unwrapping works and now FAR manager gets wrapped on copy.

Notes from internal filer

I'm on 3.0.0.5656 x64. I had repro with some older version as well, I installed the latest to check if it was fixed. Copy like you do in any other cmd window. For example, select any text file and press F3 to open the text viewer, or press CTRL+O to hide panels and view console / Far version. Now click on icon in left top corner of the window, then in menu select Edit -> Mark and select any text. Then paste the text in any other application like Notepad.

MSFT:28821591

nico-abram commented 2 years ago

I tried to reproduce both via shift+select with mouse after Ctrl+O followed by ctrl+C and also by shift+right arrow key and ctrl+C in the Far text editor, and neither copied an extra line ending, and they correctly copied a line ending in the middle when I select two lines. I also tried vertical selection via alt+shift+click and it also seems to work OK.

o-sdn-o commented 2 years ago

Perhaps this behavior is due to the fact that all EOL characters (CR and LF) are non-printable and cannot be in the scrollback buffer, and Far Manager uses ReadConsoleOutput Win32 API to capture the contents of the scrollback, and then possibly prints it as a rectangular block to the Ctrl+O screen. From the terminal's point of view, the content of the scrollback after that is a fullscreen rectangular area filled with colored cells (black is also a color; a whitespace is also a character). Therefore, logically, when you copy a linear selection with the terminal (e.g. Shift+LeftMouseDrag), the terminal should concatenate successive lines into one long line. While the terminal can apply some heuristics to detect line endings, this doesn't always work.

When you copy a rectangular selection block (using +Alt modifier), the terminal explicitly inserts a line endings after each copied row.