diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-06-04 07:39:05 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-04 07:39:05 +0800 |
commit | 53f30de2becded95f9113b75367a9dd7563c183e (patch) | |
tree | dbb09ebf6f9582284ade524df72bb937137b0b54 /src | |
parent | 0a439e38634542fd961bb4f04b1cdda304cb1bb5 (diff) | |
download | rneovim-53f30de2becded95f9113b75367a9dd7563c183e.tar.gz rneovim-53f30de2becded95f9113b75367a9dd7563c183e.tar.bz2 rneovim-53f30de2becded95f9113b75367a9dd7563c183e.zip |
vim-patch:9.0.1602: stray character visible if marker on top of double-wide char (#23897)
Problem: Stray character is visible if 'smoothscroll' marker is displayed
on top of a double-wide character.
Solution: When overwriting a double-width character with the 'smoothscroll'
marker clear the second half. (closes vim/vim#12469)
https://github.com/vim/vim/commit/ecb87dd7d3f7b9291092a7dd8fae1e59b9903252
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/grid.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/nvim/grid.c b/src/nvim/grid.c index aa542c5a2f..f2ceb2ac24 100644 --- a/src/nvim/grid.c +++ b/src/nvim/grid.c @@ -500,8 +500,6 @@ static int grid_char_needs_redraw(ScreenGrid *grid, size_t off_from, size_t off_ void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int endcol, int clear_width, int rlflag, win_T *wp, int bg_attr, bool wrap) { - size_t max_off_from; - size_t max_off_to; int col = 0; bool redraw_next; // redraw_this for next character bool clear_next = false; @@ -519,6 +517,7 @@ void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int endcol, int cle endcol = grid->cols; } + const size_t max_off_from = (size_t)grid->cols; grid_adjust(&grid, &row, &coloff); // Safety check. Avoids clang warnings down the call stack. @@ -529,8 +528,7 @@ void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int endcol, int cle size_t off_from = 0; size_t off_to = grid->line_offset[row] + (size_t)coloff; - max_off_from = linebuf_size; - max_off_to = grid->line_offset[row] + (size_t)grid->cols; + const size_t max_off_to = grid->line_offset[row] + (size_t)grid->cols; // Take care of putting "<<<" on the first line for 'smoothscroll'. if (topline && wp->w_skipcol > 0 @@ -538,18 +536,23 @@ void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int endcol, int cle && *get_showbreak_value(wp) == NUL // do not overwrite the 'listchars' "precedes" text with "<<<" && !(wp->w_p_list && wp->w_p_lcs_chars.prec != 0)) { - int off = 0; - int skip = 0; + size_t off = 0; + size_t skip = 0; if (wp->w_p_nu && wp->w_p_rnu) { // do not overwrite the line number, change "123 text" to // "123>>>xt". - while (skip < wp->w_width_inner && ascii_isdigit(*linebuf_char[off])) { + while (skip < max_off_from && ascii_isdigit(*linebuf_char[off])) { off++; skip++; } } - for (int i = 0; i < 3 && i + skip < wp->w_width_inner; i++) { + for (size_t i = 0; i < 3 && i + skip < max_off_from; i++) { + if (line_off2cells(linebuf_char, off, max_off_from) > 1) { + // When the first half of a double-width character is + // overwritten, change the second half to a space. + schar_from_ascii(linebuf_char[off + 1], ' '); + } schar_from_ascii(linebuf_char[off], '<'); linebuf_attr[off] = HL_ATTR(HLF_AT); off++; |