fix: pasting in terminal buffer on windows #22566

Problem:
On Windows, pasting multiple lines on a terminal buffer cause all the
lines to appear on the same line, i.e., the line breaks are lost.

Cause:
Windows shells expect "\r\n" as line break but "terminal_paste" function
uses "\n".

Solution:
Use "\r\n" as line break for pasting in terminal buffer on Windows.

Note:
Although this issue was reported with powershell set as 'shell', it
occurs in cmd too.

Fixes #14621
This commit is contained in:
Enan Ajmain
2023-03-19 23:23:34 +06:00
committed by GitHub
parent 65046c830e
commit 8786b2066d
2 changed files with 72 additions and 0 deletions

View File

@@ -723,7 +723,11 @@ void terminal_paste(long count, char **y_array, size_t y_size)
for (size_t j = 0; j < y_size; j++) {
if (j) {
// terminate the previous line
#ifdef MSWIN
terminal_send(curbuf->terminal, "\r\n", 2);
#else
terminal_send(curbuf->terminal, "\n", 1);
#endif
}
size_t len = strlen(y_array[j]);
if (len > buff_len) {