diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-05-17 21:09:28 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-17 21:09:28 +0800 |
commit | f49699737c9b24e1af52719974cf3bc770539ef9 (patch) | |
tree | 045c760d2904da291a95c7e0e0a452c9ddc9008d /src | |
parent | bbfc4567dfabc8d4378ad26a2d1020e3b2565107 (diff) | |
download | rneovim-f49699737c9b24e1af52719974cf3bc770539ef9.tar.gz rneovim-f49699737c9b24e1af52719974cf3bc770539ef9.tar.bz2 rneovim-f49699737c9b24e1af52719974cf3bc770539ef9.zip |
fix(terminal): do not trim whitespace that is actually in the terminal (#16423)
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/terminal.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index 2d3102707c..c8f70d4afd 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -1374,26 +1374,21 @@ static void fetch_row(Terminal *term, int row, int end_col) while (col < end_col) { VTermScreenCell cell; fetch_cell(term, row, col, &cell); - int cell_len = 0; if (cell.chars[0]) { + int cell_len = 0; for (int i = 0; cell.chars[i]; i++) { cell_len += utf_char2bytes((int)cell.chars[i], ptr + cell_len); } - } else { - *ptr = ' '; - cell_len = 1; - } - char c = *ptr; - ptr += cell_len; - if (c != ' ') { - // only increase the line length if the last character is not whitespace + ptr += cell_len; line_len = (size_t)(ptr - term->textbuf); + } else { + *ptr++ = ' '; } col += cell.width; } - // trim trailing whitespace - term->textbuf[line_len] = 0; + // end of line + term->textbuf[line_len] = NUL; } static bool fetch_cell(Terminal *term, int row, int col, VTermScreenCell *cell) |