summaryrefslogtreecommitdiffstats
path: root/src/testdir
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-03-14 18:22:17 +0100
committerChristian Brabandt <cb@256bit.org>2024-03-14 18:22:17 +0100
commit010e1539d67442cc69a97bef6453efaf849d0db3 (patch)
tree3e5566577624a5a4b3c9ba437b8b29944bb3980c /src/testdir
parent9352c282928f6cb25060249c157a28803c6efa9d (diff)
patch 9.1.0180: Cursor pos wrong when double-width chars are concealedv9.1.0180
Problem: Cursor pos wrong when double-width chars are concealed. Solution: Advance one more virtual column for a double-width char. Run some tests with both 'wrap' and 'nowrap' (zeertzjq). closes: #14197 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/testdir')
-rw-r--r--src/testdir/dumps/Test_conceal_double_width_1.dump4
-rw-r--r--src/testdir/dumps/Test_conceal_double_width_2.dump4
-rw-r--r--src/testdir/dumps/Test_conceal_double_width_3.dump4
-rw-r--r--src/testdir/dumps/Test_conceal_double_width_4.dump4
-rw-r--r--src/testdir/dumps/Test_conceal_double_width_wrap_1.dump4
-rw-r--r--src/testdir/dumps/Test_conceal_double_width_wrap_2.dump4
-rw-r--r--src/testdir/dumps/Test_conceal_double_width_wrap_3.dump4
-rw-r--r--src/testdir/dumps/Test_conceal_double_width_wrap_4.dump4
-rw-r--r--src/testdir/test_conceal.vim84
9 files changed, 107 insertions, 9 deletions
diff --git a/src/testdir/dumps/Test_conceal_double_width_1.dump b/src/testdir/dumps/Test_conceal_double_width_1.dump
new file mode 100644
index 0000000000..57353bbc95
--- /dev/null
+++ b/src/testdir/dumps/Test_conceal_double_width_1.dump
@@ -0,0 +1,4 @@
+|a+0&#ffffff0@4|β+0#e0e0e08#6c6c6c255|b+0#0000000#ffffff0@4|β+0#e0e0e08#6c6c6c255|c+0#0000000#ffffff0@3>c| @11| +0&#ffd7d7255| +0&#ffffff0@44
+|f|o@1|b|a|r| @22| +0&#ffd7d7255| +0&#ffffff0@44
+|~+0#4040ff13&| @73
+| +0#0000000&@56|1|,|2|9|-|2|5| @6|A|l@1|
diff --git a/src/testdir/dumps/Test_conceal_double_width_2.dump b/src/testdir/dumps/Test_conceal_double_width_2.dump
new file mode 100644
index 0000000000..782db47481
--- /dev/null
+++ b/src/testdir/dumps/Test_conceal_double_width_2.dump
@@ -0,0 +1,4 @@
+|a+0&#ffffff0@4|β+0#e0e0e08#6c6c6c255|b+0#0000000#ffffff0@1>b@2|β+0#e0e0e08#6c6c6c255|c+0#0000000#ffffff0@4| @11| +0&#ffd7d7255| +0&#ffffff0@44
+|f|o@1|b|a|r| @22| +0&#ffd7d7255| +0&#ffffff0@44
+|~+0#4040ff13&| @73
+| +0#0000000&@56|1|,|1|5|-|1|3| @6|A|l@1|
diff --git a/src/testdir/dumps/Test_conceal_double_width_3.dump b/src/testdir/dumps/Test_conceal_double_width_3.dump
new file mode 100644
index 0000000000..5102c7b781
--- /dev/null
+++ b/src/testdir/dumps/Test_conceal_double_width_3.dump
@@ -0,0 +1,4 @@
+|a+0&#ffffff0@4|b@1>b@2|c@4| @13| +0&#ffd7d7255| +0&#ffffff0@44
+|f|o@1|b|a|r| @22| +0&#ffd7d7255| +0&#ffffff0@44
+|~+0#4040ff13&| @73
+|:+0#0000000&|s|e|t| |c|o|n|c|e|a|l@1|e|v|e|l|=|3| @37|1|,|1|5|-|1|3| @6|A|l@1|
diff --git a/src/testdir/dumps/Test_conceal_double_width_4.dump b/src/testdir/dumps/Test_conceal_double_width_4.dump
new file mode 100644
index 0000000000..8ef8b96532
--- /dev/null
+++ b/src/testdir/dumps/Test_conceal_double_width_4.dump
@@ -0,0 +1,4 @@
+|a+0&#ffffff0@4|b@4|c@3>c| @13| +0&#ffd7d7255| +0&#ffffff0@44
+|f|o@1|b|a|r| @22| +0&#ffd7d7255| +0&#ffffff0@44
+|~+0#4040ff13&| @73
+|:+0#0000000&|s|e|t| |c|o|n|c|e|a|l@1|e|v|e|l|=|3| @37|1|,|2|9|-|2|5| @6|A|l@1|
diff --git a/src/testdir/dumps/Test_conceal_double_width_wrap_1.dump b/src/testdir/dumps/Test_conceal_double_width_wrap_1.dump
new file mode 100644
index 0000000000..e794b7c8f1
--- /dev/null
+++ b/src/testdir/dumps/Test_conceal_double_width_wrap_1.dump
@@ -0,0 +1,4 @@
+|a+0&#ffffff0@9|β+0#e0e0e08#6c6c6c255|b+0#0000000#ffffff0@4| @3
+|b@4|β+0#e0e0e08#6c6c6c255|c+0#0000000#ffffff0@8>c| @3
+|~+0#4040ff13&| @18
+| +0#0000000&@9|1|,|4@1|-|4|0| @2
diff --git a/src/testdir/dumps/Test_conceal_double_width_wrap_2.dump b/src/testdir/dumps/Test_conceal_double_width_wrap_2.dump
new file mode 100644
index 0000000000..36e64fc6a8
--- /dev/null
+++ b/src/testdir/dumps/Test_conceal_double_width_wrap_2.dump
@@ -0,0 +1,4 @@
+|a+0&#ffffff0@9|β+0#e0e0e08#6c6c6c255|b+0#0000000#ffffff0@4| @3
+>b@4|β+0#e0e0e08#6c6c6c255|c+0#0000000#ffffff0@9| @3
+|~+0#4040ff13&| @18
+| +0#0000000&@9|1|,|2|3|-|2|1| @2
diff --git a/src/testdir/dumps/Test_conceal_double_width_wrap_3.dump b/src/testdir/dumps/Test_conceal_double_width_wrap_3.dump
new file mode 100644
index 0000000000..ba6c8357a9
--- /dev/null
+++ b/src/testdir/dumps/Test_conceal_double_width_wrap_3.dump
@@ -0,0 +1,4 @@
+|a+0&#ffffff0@9|b@4| @4
+>b@4|c@9| @4
+|~+0#4040ff13&| @18
+|:+0#0000000&|s|e|t| |c|o|n|c|e|1|,|2|3|-|2|1| @2
diff --git a/src/testdir/dumps/Test_conceal_double_width_wrap_4.dump b/src/testdir/dumps/Test_conceal_double_width_wrap_4.dump
new file mode 100644
index 0000000000..8997e98ab7
--- /dev/null
+++ b/src/testdir/dumps/Test_conceal_double_width_wrap_4.dump
@@ -0,0 +1,4 @@
+|a+0&#ffffff0@9|b@4| @4
+|b@4|c@8>c| @4
+|~+0#4040ff13&| @18
+|:+0#0000000&| @8|1|,|4@1|-|4|0| @2
diff --git a/src/testdir/test_conceal.vim b/src/testdir/test_conceal.vim
index 7080fdd1f0..1cc08fcf84 100644
--- a/src/testdir/test_conceal.vim
+++ b/src/testdir/test_conceal.vim
@@ -441,7 +441,7 @@ func Test_conceal_mouse_click()
call test_setmouse(1, 19)
call feedkeys("\<LeftMouse>", "tx")
call assert_equal([0, 1, 23, 0, 23], getcurpos())
- " click after end of line puts cursor there without 'virtualedit'
+ " click after end of line puts cursor there with 'virtualedit'
call test_setmouse(1, 20)
call feedkeys("\<LeftMouse>", "tx")
call assert_equal([0, 1, 24, 0, 24], getcurpos())
@@ -464,10 +464,9 @@ endfunc
" Test that cursor is drawn at the correct column when it is after end of the
" line with 'virtualedit' and concealing.
-func Test_conceal_virtualedit_after_eol()
- CheckScreendump
-
- let code =<< trim [CODE]
+func Run_test_conceal_virtualedit_after_eol(wrap)
+ let code =<< trim eval [CODE]
+ let &wrap = {a:wrap}
call setline(1, 'abcdefgh|hidden|ijklmnpop')
syntax match test /|hidden|/ conceal
set conceallevel=2 concealcursor=n virtualedit=all
@@ -489,12 +488,17 @@ func Test_conceal_virtualedit_after_eol()
call StopVimInTerminal(buf)
endfunc
-" Same as Test_conceal_virtualedit_after_eol(), but with 'rightleft' set.
-func Test_conceal_virtualedit_after_eol_rightleft()
- CheckFeature rightleft
+func Test_conceal_virtualedit_after_eol()
CheckScreendump
- let code =<< trim [CODE]
+ call Run_test_conceal_virtualedit_after_eol(1)
+ call Run_test_conceal_virtualedit_after_eol(0)
+endfunc
+
+" Same as Run_test_conceal_virtualedit_after_eol(), but with 'rightleft'.
+func Run_test_conceal_virtualedit_after_eol_rightleft(wrap)
+ let code =<< trim eval [CODE]
+ let &wrap = {a:wrap}
call setline(1, 'abcdefgh|hidden|ijklmnpop')
syntax match test /|hidden|/ conceal
set conceallevel=2 concealcursor=n virtualedit=all rightleft
@@ -516,4 +520,66 @@ func Test_conceal_virtualedit_after_eol_rightleft()
call StopVimInTerminal(buf)
endfunc
+func Test_conceal_virtualedit_after_eol_rightleft()
+ CheckFeature rightleft
+ CheckScreendump
+
+ call Run_test_conceal_virtualedit_after_eol_rightleft(1)
+ call Run_test_conceal_virtualedit_after_eol_rightleft(0)
+endfunc
+
+" Test that cursor position is correct when double-width chars are concealed.
+func Run_test_conceal_double_width(wrap)
+ let code =<< trim eval [CODE]
+ let &wrap = {a:wrap}
+ call setline(1, ['aaaaa口=口bbbbb口=口ccccc', 'foobar'])
+ syntax match test /口=口/ conceal cchar=β
+ set conceallevel=2 concealcursor=n colorcolumn=30
+ normal! $
+ [CODE]
+ call writefile(code, 'XTest_conceal_double_width', 'D')
+ let buf = RunVimInTerminal('-S XTest_conceal_double_width', {'rows': 4})
+ call VerifyScreenDump(buf, 'Test_conceal_double_width_1', {})
+ call term_sendkeys(buf, "gM")
+ call VerifyScreenDump(buf, 'Test_conceal_double_width_2', {})
+ call term_sendkeys(buf, ":set conceallevel=3\<CR>")
+ call VerifyScreenDump(buf, 'Test_conceal_double_width_3', {})
+ call term_sendkeys(buf, "$")
+ call VerifyScreenDump(buf, 'Test_conceal_double_width_4', {})
+
+ " clean up
+ call StopVimInTerminal(buf)
+endfunc
+
+func Test_conceal_double_width()
+ CheckScreendump
+
+ call Run_test_conceal_double_width(1)
+ call Run_test_conceal_double_width(0)
+endfunc
+
+" Test that line wrapping is correct when double-width chars are concealed.
+func Test_conceal_double_width_wrap()
+ CheckScreendump
+
+ let code =<< trim [CODE]
+ call setline(1, 'aaaaaaaaaa口=口bbbbbbbbbb口=口cccccccccc')
+ syntax match test /口=口/ conceal cchar=β
+ set conceallevel=2 concealcursor=n
+ normal! $
+ [CODE]
+ call writefile(code, 'XTest_conceal_double_width_wrap', 'D')
+ let buf = RunVimInTerminal('-S XTest_conceal_double_width_wrap', {'rows': 4, 'cols': 20})
+ call VerifyScreenDump(buf, 'Test_conceal_double_width_wrap_1', {})
+ call term_sendkeys(buf, "gM")
+ call VerifyScreenDump(buf, 'Test_conceal_double_width_wrap_2', {})
+ call term_sendkeys(buf, ":set conceallevel=3\<CR>")
+ call VerifyScreenDump(buf, 'Test_conceal_double_width_wrap_3', {})
+ call term_sendkeys(buf, "$")
+ call VerifyScreenDump(buf, 'Test_conceal_double_width_wrap_4', {})
+
+ " clean up
+ call StopVimInTerminal(buf)
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab