Skip to content

Commit b5d6b5c

Browse files
zeertzjqchrisbra
authored andcommitted
patch 9.1.0601: Wrong cursor position with 'breakindent' when wide char doesn't fit
Problem: Wrong cursor position with 'breakindent' when a double-width character doesn't fit in a screen line (mikoto2000) Solution: Include the width of the 'breakindent' properly. (zeertzjq) fixes: #15289 closes: #15290 Signed-off-by: zeertzjq <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 99984fc commit b5d6b5c

8 files changed

Lines changed: 38 additions & 3 deletions

src/charset.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,17 +1397,17 @@ win_lbr_chartabsize(
13971397
else if (max_head_vcol > vcol + head_prev + prev_rem)
13981398
head += (max_head_vcol - (vcol + head_prev + prev_rem)
13991399
+ width2 - 1) / width2 * head_mid;
1400-
# ifdef FEAT_PROP_POPUP
14011400
else if (max_head_vcol < 0)
14021401
{
1403-
int off = 0;
1402+
int off = mb_added;
1403+
# ifdef FEAT_PROP_POPUP
14041404
if (*s != NUL
14051405
&& ((State & MODE_NORMAL) || cts->cts_start_incl))
14061406
off += cts->cts_cur_text_width;
1407+
# endif
14071408
if (off >= prev_rem)
14081409
head += (1 + (off - prev_rem) / width) * head_mid;
14091410
}
1410-
# endif
14111411
}
14121412
}
14131413

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
| +0&#ffffff0@7|a@40|>+0#4040ff13&
2+
| +0#0000000&@7>口*&@2| +&@35
3+
|~+0#4040ff13&| @48
4+
|~| @48
5+
|~| @48
6+
| +0#0000000&@31|1|,|4|3|-|5|9| @6|A|l@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|1|-|5|1| @6|A|l@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+
|+@2>口*0#0000000&|1+&|2|3|4|5| @39
3+
|:|s|e|t| |s|h|o|w|b|r|e|a|k|=|+@2| @13|1|,|4|1|-|5|4| @6|A|l@1|

src/testdir/test_breakindent.vim

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,4 +1165,15 @@ func Test_breakindent_min_with_signcol()
11651165
call s:close_windows()
11661166
endfunc
11671167

1168+
func Test_breakindent_with_double_width_wrap()
1169+
50vnew
1170+
setlocal tabstop=8 breakindent nolist
1171+
call setline(1, "\t" .. repeat('a', winwidth(0) - 9) .. '口口口')
1172+
normal! $g0
1173+
call assert_equal(2, winline())
1174+
call assert_equal(9, wincol())
1175+
1176+
bwipe!
1177+
endfunc
1178+
11681179
" vim: shiftwidth=2 sts=2 expandtab

src/testdir/test_listlbr_utf8.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@ func Test_chinese_char_on_wrap_column()
280280
call s:compare_lines(expect, lines)
281281
call assert_equal(len(expect), winline())
282282
call assert_equal(strwidth(trim(expect[-1], ' ', 2)), wincol())
283+
norm! g0
284+
call assert_equal(len(expect), winline())
285+
call assert_equal(1, wincol())
283286
call s:close_windows()
284287
endfunc
285288

@@ -315,6 +318,9 @@ func Test_chinese_char_on_wrap_column_sbr()
315318
call s:compare_lines(expect, lines)
316319
call assert_equal(len(expect), winline())
317320
call assert_equal(strwidth(trim(expect[-1], ' ', 2)), wincol())
321+
norm! g0
322+
call assert_equal(len(expect), winline())
323+
call assert_equal(4, wincol())
318324
call s:close_windows()
319325
endfunc
320326

src/testdir/test_textprop.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2901,6 +2901,10 @@ func Test_prop_inserts_text_before_double_width_wrap()
29012901
call writefile(lines, 'XscriptPropsBeforeDoubleWidthWrap', 'D')
29022902
let buf = RunVimInTerminal('-S XscriptPropsBeforeDoubleWidthWrap', #{rows: 3, cols: 50})
29032903
call VerifyScreenDump(buf, 'Test_prop_inserts_text_before_double_width_wrap_1', {})
2904+
call term_sendkeys(buf, 'g0')
2905+
call VerifyScreenDump(buf, 'Test_prop_inserts_text_before_double_width_wrap_2', {})
2906+
call term_sendkeys(buf, ":set showbreak=+++\<CR>")
2907+
call VerifyScreenDump(buf, 'Test_prop_inserts_text_before_double_width_wrap_3', {})
29042908

29052909
call StopVimInTerminal(buf)
29062910
endfunc

src/version.c

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

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
601,
707709
/**/
708710
600,
709711
/**/

0 commit comments

Comments
 (0)