From bc75544facbf200fc7a7d519c0963ec1becfa508 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 24 Dec 2021 08:06:26 +0800 Subject: fix(screen): truncate double-width character correctly The `c = '>';` is useless here, because it is not used later. `u8c` should also need to be set to '>', and `u8cc` needs to be cleared. --- src/nvim/screen.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/nvim/screen.c') diff --git a/src/nvim/screen.c b/src/nvim/screen.c index a938a3b062..df911a1228 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -5933,6 +5933,8 @@ void grid_puts_len(ScreenGrid *grid, char_u *text, int textlen, int row, int col // Only 1 cell left, but character requires 2 cells: // display a '>' in the last column to avoid wrapping. */ c = '>'; + u8c = '>'; + u8cc[0] = 0; mbyte_cells = 1; } -- cgit From 28dadd5a54a67b467c08614670c65b0b5b23d247 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 24 Dec 2021 08:06:27 +0800 Subject: fix(screen): truncate when overwriting right half of a double-width char Unlike the code above, this truncates the character in the same grid. This is mainly for the pum scrollbar in the next commit. --- src/nvim/screen.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/nvim/screen.c') diff --git a/src/nvim/screen.c b/src/nvim/screen.c index df911a1228..e62e3ca7bc 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -5965,6 +5965,13 @@ void grid_puts_len(ScreenGrid *grid, char_u *text, int textlen, int row, int col clear_next_cell = true; } + // When at the start of the text and overwriting the right half of a + // two-cell character in the same grid, truncate that into a '>'. + if (ptr == text && col > 0 && grid->chars[off][0] == 0) { + grid->chars[off - 1][0] = '>'; + grid->chars[off - 1][1] = 0; + } + schar_copy(grid->chars[off], buf); grid->attrs[off] = attr; if (mbyte_cells == 2) { -- cgit