Skip to content

Commit ac2d881

Browse files
zeertzjqchrisbra
authored andcommitted
patch 9.0.1828: cursor wrong with virt text before double-width char
Problem: Wrong cursor position with virtual text before double-width char at window edge. Solution: Check for double-width char before adding virtual text size. closes: #12977 Signed-off-by: Christian Brabandt <[email protected]> Co-authored-by: zeertzjq <[email protected]>
1 parent e102e44 commit ac2d881

4 files changed

Lines changed: 25 additions & 2 deletions

File tree

src/charset.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,6 +1159,9 @@ win_lbr_chartabsize(
11591159
size = win_chartabsize(wp, s, vcol);
11601160
if (*s == NUL && !has_lcs_eol)
11611161
size = 0; // NUL is not displayed
1162+
# ifdef FEAT_LINEBREAK
1163+
int is_doublewidth = has_mbyte && size == 2 && MB_BYTE2LEN(*s) > 1;
1164+
# endif
11621165

11631166
# ifdef FEAT_PROP_POPUP
11641167
if (cts->cts_has_prop_with_text)
@@ -1242,8 +1245,7 @@ win_lbr_chartabsize(
12421245
# endif
12431246

12441247
# ifdef FEAT_LINEBREAK
1245-
if (has_mbyte && size == 2 && MB_BYTE2LEN(*s) > 1
1246-
&& wp->w_p_wrap && in_win_border(wp, vcol))
1248+
if (is_doublewidth && wp->w_p_wrap && in_win_border(wp, vcol + size - 2))
12471249
{
12481250
++size; // Count the ">" in the last column.
12491251
mb_added = 1;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
|a+0&#ffffff0@39|b+0#e000e06&@8|>+0#4040ff13&
2+
|口*0#0000000&|1+&|2|3|4>5| @42
3+
@32|1|,|4|8|-|5|7| @6|A|l@1|

src/testdir/test_textprop.vim

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2810,6 +2810,22 @@ func Test_prop_inserts_text_before_linebreak()
28102810
call StopVimInTerminal(buf)
28112811
endfunc
28122812

2813+
func Test_prop_inserts_text_before_double_width_wrap()
2814+
CheckRunVimInTerminal
2815+
2816+
let lines =<< trim END
2817+
call setline(1, repeat('a', 40) .. '' .. '12345')
2818+
call prop_type_add('theprop', #{highlight: 'Special'})
2819+
call prop_add(1, 41, #{type: 'theprop', text: repeat('b', 9)})
2820+
normal! $
2821+
END
2822+
call writefile(lines, 'XscriptPropsBeforeDoubleWidthWrap', 'D')
2823+
let buf = RunVimInTerminal('-S XscriptPropsBeforeDoubleWidthWrap', #{rows: 3, cols: 50})
2824+
call VerifyScreenDump(buf, 'Test_prop_inserts_text_before_double_width_wrap_1', {})
2825+
2826+
call StopVimInTerminal(buf)
2827+
endfunc
2828+
28132829
func Test_prop_inserts_text_lcs_extends()
28142830
CheckRunVimInTerminal
28152831

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,8 @@ static char *(features[]) =
699699

700700
static int included_patches[] =
701701
{ /* Add new patch number below this line */
702+
/**/
703+
1828,
702704
/**/
703705
1827,
704706
/**/

0 commit comments

Comments
 (0)