From abc808112ee5df58a9f612f2bb5a65389c2c14e1 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 24 Sep 2023 23:32:18 +0200 Subject: patch 9.0.1938: multispace wrong when scrolling horizontally Problem: multispace wrong when scrolling horizontally Solution: Update position in "multispace" or "leadmultispace" also in skipped chars. Reorder conditions to be more consistent. closes: #13145 closes: #13147 Signed-off-by: Christian Brabandt Co-authored-by: zeertzjq --- src/drawline.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'src/drawline.c') diff --git a/src/drawline.c b/src/drawline.c index 95ea3f025a..4d63fae34d 100644 --- a/src/drawline.c +++ b/src/drawline.c @@ -1684,6 +1684,27 @@ win_line( cts.cts_vcol += charsize; prev_ptr = cts.cts_ptr; MB_PTR_ADV(cts.cts_ptr); + if (wp->w_p_list) + { + in_multispace = *prev_ptr == ' ' && (*cts.cts_ptr == ' ' + || (prev_ptr > line && prev_ptr[-1] == ' ')); + if (!in_multispace) + multispace_pos = 0; + else if (cts.cts_ptr >= line + leadcol + && wp->w_lcs_chars.multispace != NULL) + { + ++multispace_pos; + if (wp->w_lcs_chars.multispace[multispace_pos] == NUL) + multispace_pos = 0; + } + else if (cts.cts_ptr < line + leadcol + && wp->w_lcs_chars.leadmultispace != NULL) + { + ++multispace_pos; + if (wp->w_lcs_chars.leadmultispace[multispace_pos] == NUL) + multispace_pos = 0; + } + } } wlv.vcol = cts.cts_vcol; ptr = cts.cts_ptr; @@ -2589,9 +2610,7 @@ win_line( #ifdef FEAT_LINEBREAK int c0; #endif -#ifdef FEAT_SPELL char_u *prev_ptr = ptr; -#endif // Get a character from the line itself. c = *ptr; @@ -2941,10 +2960,13 @@ win_line( } } #endif - in_multispace = c == ' ' - && ((ptr > line + 1 && ptr[-2] == ' ') || *ptr == ' '); - if (!in_multispace) - multispace_pos = 0; + if (wp->w_p_list) + { + in_multispace = c == ' ' && (*ptr == ' ' + || (prev_ptr > line && prev_ptr[-1] == ' ')); + if (!in_multispace) + multispace_pos = 0; + } // 'list': Change char 160 to 'nbsp' and space to 'space' // setting in 'listchars'. But not when the character is -- cgit v1.2.3