Skip to content

Commit abc8081

Browse files
zeertzjqchrisbra
authored andcommitted
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 <[email protected]> Co-authored-by: zeertzjq <[email protected]>
1 parent 46a0582 commit abc8081

4 files changed

Lines changed: 129 additions & 125 deletions

File tree

src/drawline.c

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,6 +1684,27 @@ win_line(
16841684
cts.cts_vcol += charsize;
16851685
prev_ptr = cts.cts_ptr;
16861686
MB_PTR_ADV(cts.cts_ptr);
1687+
if (wp->w_p_list)
1688+
{
1689+
in_multispace = *prev_ptr == ' ' && (*cts.cts_ptr == ' '
1690+
|| (prev_ptr > line && prev_ptr[-1] == ' '));
1691+
if (!in_multispace)
1692+
multispace_pos = 0;
1693+
else if (cts.cts_ptr >= line + leadcol
1694+
&& wp->w_lcs_chars.multispace != NULL)
1695+
{
1696+
++multispace_pos;
1697+
if (wp->w_lcs_chars.multispace[multispace_pos] == NUL)
1698+
multispace_pos = 0;
1699+
}
1700+
else if (cts.cts_ptr < line + leadcol
1701+
&& wp->w_lcs_chars.leadmultispace != NULL)
1702+
{
1703+
++multispace_pos;
1704+
if (wp->w_lcs_chars.leadmultispace[multispace_pos] == NUL)
1705+
multispace_pos = 0;
1706+
}
1707+
}
16871708
}
16881709
wlv.vcol = cts.cts_vcol;
16891710
ptr = cts.cts_ptr;
@@ -2589,9 +2610,7 @@ win_line(
25892610
#ifdef FEAT_LINEBREAK
25902611
int c0;
25912612
#endif
2592-
#ifdef FEAT_SPELL
25932613
char_u *prev_ptr = ptr;
2594-
#endif
25952614

25962615
// Get a character from the line itself.
25972616
c = *ptr;
@@ -2941,10 +2960,13 @@ win_line(
29412960
}
29422961
}
29432962
#endif
2944-
in_multispace = c == ' '
2945-
&& ((ptr > line + 1 && ptr[-2] == ' ') || *ptr == ' ');
2946-
if (!in_multispace)
2947-
multispace_pos = 0;
2963+
if (wp->w_p_list)
2964+
{
2965+
in_multispace = c == ' ' && (*ptr == ' '
2966+
|| (prev_ptr > line && prev_ptr[-1] == ' '));
2967+
if (!in_multispace)
2968+
multispace_pos = 0;
2969+
}
29482970

29492971
// 'list': Change char 160 to 'nbsp' and space to 'space'
29502972
// setting in 'listchars'. But not when the character is

src/message.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2005,10 +2005,13 @@ msg_prt_line(char_u *s, int list)
20052005
{
20062006
attr = 0;
20072007
c = *s++;
2008-
in_multispace = c == ' '
2009-
&& ((col > 0 && s[-2] == ' ') || *s == ' ');
2010-
if (!in_multispace)
2011-
multispace_pos = 0;
2008+
if (list)
2009+
{
2010+
in_multispace = c == ' ' && (*s == ' '
2011+
|| (col > 0 && s[-2] == ' '));
2012+
if (!in_multispace)
2013+
multispace_pos = 0;
2014+
}
20122015
if (c == TAB && (!list || curwin->w_lcs_chars.tab1))
20132016
{
20142017
// tab amount depends on current column
@@ -2062,7 +2065,7 @@ msg_prt_line(char_u *s, int list)
20622065
}
20632066
else if (c == ' ')
20642067
{
2065-
if (list && lead != NULL && s <= lead && in_multispace
2068+
if (lead != NULL && s <= lead && in_multispace
20662069
&& curwin->w_lcs_chars.leadmultispace != NULL)
20672070
{
20682071
c = curwin->w_lcs_chars.leadmultispace[multispace_pos++];
@@ -2082,7 +2085,7 @@ msg_prt_line(char_u *s, int list)
20822085
c = curwin->w_lcs_chars.trail;
20832086
attr = HL_ATTR(HLF_8);
20842087
}
2085-
else if (list && in_multispace
2088+
else if (in_multispace
20862089
&& curwin->w_lcs_chars.multispace != NULL)
20872090
{
20882091
c = curwin->w_lcs_chars.multispace[multispace_pos++];

0 commit comments

Comments
 (0)