summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-07-18 21:13:31 +0200
committerChristian Brabandt <cb@256bit.org>2024-07-18 21:13:31 +0200
commitb5d6b5caac752fe15856e37fd3abc5459292d4b8 (patch)
treefaf7fb69cf2330b4909187f3a5187b513c12625a
parent99984fc58abf8dd5dac76c80635a724a94824e69 (diff)
patch 9.1.0601: Wrong cursor position with 'breakindent' when wide char doesn't fitv9.1.0601
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 <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
-rw-r--r--src/charset.c6
-rw-r--r--src/testdir/dumps/Test_breakindent_with_double_width_wrap_1.dump6
-rw-r--r--src/testdir/dumps/Test_prop_inserts_text_before_double_width_wrap_2.dump3
-rw-r--r--src/testdir/dumps/Test_prop_inserts_text_before_double_width_wrap_3.dump3
-rw-r--r--src/testdir/test_breakindent.vim11
-rw-r--r--src/testdir/test_listlbr_utf8.vim6
-rw-r--r--src/testdir/test_textprop.vim4
-rw-r--r--src/version.c2
8 files changed, 38 insertions, 3 deletions
diff --git a/src/charset.c b/src/charset.c
index 45b16aa3ab..19b089526a 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -1397,17 +1397,17 @@ win_lbr_chartabsize(
else if (max_head_vcol > vcol + head_prev + prev_rem)
head += (max_head_vcol - (vcol + head_prev + prev_rem)
+ width2 - 1) / width2 * head_mid;
-# ifdef FEAT_PROP_POPUP
else if (max_head_vcol < 0)
{
- int off = 0;
+ int off = mb_added;
+# ifdef FEAT_PROP_POPUP
if (*s != NUL
&& ((State & MODE_NORMAL) || cts->cts_start_incl))
off += cts->cts_cur_text_width;
+# endif
if (off >= prev_rem)
head += (1 + (off - prev_rem) / width) * head_mid;
}
-# endif
}
}
diff --git a/src/testdir/dumps/Test_breakindent_with_double_width_wrap_1.dump b/src/testdir/dumps/Test_breakindent_with_double_width_wrap_1.dump
new file mode 100644
index 0000000000..7b761bc1d2
--- /dev/null
+++ b/src/testdir/dumps/Test_breakindent_with_double_width_wrap_1.dump
@@ -0,0 +1,6 @@
+| +0&#ffffff0@7|a@40|>+0#4040ff13&
+| +0#0000000&@7>口*&@2| +&@35
+|~+0#4040ff13&| @48
+|~| @48
+|~| @48
+| +0#0000000&@31|1|,|4|3|-|5|9| @6|A|l@1|
diff --git a/src/testdir/dumps/Test_prop_inserts_text_before_double_width_wrap_2.dump b/src/testdir/dumps/Test_prop_inserts_text_before_double_width_wrap_2.dump
new file mode 100644
index 0000000000..6022a16368
--- /dev/null
+++ b/src/testdir/dumps/Test_prop_inserts_text_before_double_width_wrap_2.dump
@@ -0,0 +1,3 @@
+|a+0&#ffffff0@39|b+0#e000e06&@8|>+0#4040ff13&
+>口*0#0000000&|1+&|2|3|4|5| @42
+@32|1|,|4|1|-|5|1| @6|A|l@1|
diff --git a/src/testdir/dumps/Test_prop_inserts_text_before_double_width_wrap_3.dump b/src/testdir/dumps/Test_prop_inserts_text_before_double_width_wrap_3.dump
new file mode 100644
index 0000000000..c033399ac0
--- /dev/null
+++ b/src/testdir/dumps/Test_prop_inserts_text_before_double_width_wrap_3.dump
@@ -0,0 +1,3 @@
+|a+0&#ffffff0@39|b+0#e000e06&@8|>+0#4040ff13&
+|+@2>口*0#0000000&|1+&|2|3|4|5| @39
+|:|s|e|t| |s|h|o|w|b|r|e|a|k|=|+@2| @13|1|,|4|1|-|5|4| @6|A|l@1|
diff --git a/src/testdir/test_breakindent.vim b/src/testdir/test_breakindent.vim
index 96d91c949c..b306c02078 100644
--- a/src/testdir/test_breakindent.vim
+++ b/src/testdir/test_breakindent.vim
@@ -1165,4 +1165,15 @@ func Test_breakindent_min_with_signcol()
call s:close_windows()
endfunc
+func Test_breakindent_with_double_width_wrap()
+ 50vnew
+ setlocal tabstop=8 breakindent nolist
+ call setline(1, "\t" .. repeat('a', winwidth(0) - 9) .. '口口口')
+ normal! $g0
+ call assert_equal(2, winline())
+ call assert_equal(9, wincol())
+
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_listlbr_utf8.vim b/src/testdir/test_listlbr_utf8.vim
index 313ff30cc4..693f2015fc 100644
--- a/src/testdir/test_listlbr_utf8.vim
+++ b/src/testdir/test_listlbr_utf8.vim
@@ -280,6 +280,9 @@ func Test_chinese_char_on_wrap_column()
call s:compare_lines(expect, lines)
call assert_equal(len(expect), winline())
call assert_equal(strwidth(trim(expect[-1], ' ', 2)), wincol())
+ norm! g0
+ call assert_equal(len(expect), winline())
+ call assert_equal(1, wincol())
call s:close_windows()
endfunc
@@ -315,6 +318,9 @@ func Test_chinese_char_on_wrap_column_sbr()
call s:compare_lines(expect, lines)
call assert_equal(len(expect), winline())
call assert_equal(strwidth(trim(expect[-1], ' ', 2)), wincol())
+ norm! g0
+ call assert_equal(len(expect), winline())
+ call assert_equal(4, wincol())
call s:close_windows()
endfunc
diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim
index 2bf28349d7..57277f79e2 100644
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -2901,6 +2901,10 @@ func Test_prop_inserts_text_before_double_width_wrap()
call writefile(lines, 'XscriptPropsBeforeDoubleWidthWrap', 'D')
let buf = RunVimInTerminal('-S XscriptPropsBeforeDoubleWidthWrap', #{rows: 3, cols: 50})
call VerifyScreenDump(buf, 'Test_prop_inserts_text_before_double_width_wrap_1', {})
+ call term_sendkeys(buf, 'g0')
+ call VerifyScreenDump(buf, 'Test_prop_inserts_text_before_double_width_wrap_2', {})
+ call term_sendkeys(buf, ":set showbreak=+++\<CR>")
+ call VerifyScreenDump(buf, 'Test_prop_inserts_text_before_double_width_wrap_3', {})
call StopVimInTerminal(buf)
endfunc
diff --git a/src/version.c b/src/version.c
index ae733c82cd..5473fe0c43 100644
--- a/src/version.c
+++ b/src/version.c
@@ -705,6 +705,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 601,
+/**/
600,
/**/
599,