aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/grid.c19
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++;