summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-03-13 20:38:26 +0100
committerChristian Brabandt <cb@256bit.org>2024-03-13 20:38:26 +0100
commit253ff4dece4e6cc4a9ff3ed935bc78f832b6fb7c (patch)
treef30426095c5bd9e5f18442a8d2ec37051d79f8c3
parent5866bc3a0f54115d5982fdc09bdbe4c45069265a (diff)
patch 9.1.0176: Cursor column wrong with 'virtualedit' and concealv9.1.0176
Problem: Cursor column wrong with 'virtualedit' and conceal. Solution: Correct cursor column at end of line if never reached. (zeertzjq) closes: #14190 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
-rw-r--r--src/drawline.c7
-rw-r--r--src/testdir/dumps/Test_conceal_ve_after_eol_1.dump3
-rw-r--r--src/testdir/dumps/Test_conceal_ve_after_eol_2.dump3
-rw-r--r--src/testdir/dumps/Test_conceal_ve_after_eol_3.dump3
-rw-r--r--src/testdir/dumps/Test_conceal_ve_after_eol_4.dump3
-rw-r--r--src/testdir/dumps/Test_conceal_ve_after_eol_5.dump3
-rw-r--r--src/testdir/dumps/Test_conceal_ve_after_eol_rl_1.dump3
-rw-r--r--src/testdir/dumps/Test_conceal_ve_after_eol_rl_2.dump3
-rw-r--r--src/testdir/dumps/Test_conceal_ve_after_eol_rl_3.dump3
-rw-r--r--src/testdir/dumps/Test_conceal_ve_after_eol_rl_4.dump3
-rw-r--r--src/testdir/dumps/Test_conceal_ve_after_eol_rl_5.dump3
-rw-r--r--src/testdir/test_conceal.vim54
-rw-r--r--src/version.c2
13 files changed, 92 insertions, 1 deletions
diff --git a/src/drawline.c b/src/drawline.c
index 946e9bd3dd..088477faf0 100644
--- a/src/drawline.c
+++ b/src/drawline.c
@@ -3547,10 +3547,12 @@ win_line(
#ifdef FEAT_CONCEAL
// In the cursor line and we may be concealing characters: correct
// the cursor column when we reach its position.
+ // With 'virtualedit' we may never reach cursor position, but we still
+ // need to correct the cursor column, so do that at end of line.
if (!did_wcol && wlv.draw_state == WL_LINE
&& wp == curwin && lnum == wp->w_cursor.lnum
&& conceal_cursor_line(wp)
- && (int)wp->w_virtcol <= wlv.vcol + skip_cells)
+ && (wlv.vcol + skip_cells >= wp->w_virtcol || c == NUL))
{
# ifdef FEAT_RIGHTLEFT
if (wp->w_p_rl)
@@ -3558,6 +3560,9 @@ win_line(
else
# endif
wp->w_wcol = wlv.col - wlv.boguscols;
+ if (wlv.vcol + skip_cells < wp->w_virtcol)
+ // Cursor beyond end of the line with 'virtualedit'.
+ wp->w_wcol += wp->w_virtcol - wlv.vcol - skip_cells;
wp->w_wrow = wlv.row;
did_wcol = TRUE;
curwin->w_valid |= VALID_WCOL|VALID_WROW|VALID_VIRTCOL;
diff --git a/src/testdir/dumps/Test_conceal_ve_after_eol_1.dump b/src/testdir/dumps/Test_conceal_ve_after_eol_1.dump
new file mode 100644
index 0000000000..635c6db819
--- /dev/null
+++ b/src/testdir/dumps/Test_conceal_ve_after_eol_1.dump
@@ -0,0 +1,3 @@
+|a+0&#ffffff0|b|c|d|e|f|g|h|i|j|k|l|m|n|p|o>p| @57
+|~+0#4040ff13&| @73
+| +0#0000000&@56|1|,|2|5| @9|A|l@1|
diff --git a/src/testdir/dumps/Test_conceal_ve_after_eol_2.dump b/src/testdir/dumps/Test_conceal_ve_after_eol_2.dump
new file mode 100644
index 0000000000..ecdc5a332f
--- /dev/null
+++ b/src/testdir/dumps/Test_conceal_ve_after_eol_2.dump
@@ -0,0 +1,3 @@
+|a+0&#ffffff0|b|c|d|e|f|g|h|i|j|k|l|m|n|p|o|p> @57
+|~+0#4040ff13&| @73
+| +0#0000000&@56|1|,|2|6| @9|A|l@1|
diff --git a/src/testdir/dumps/Test_conceal_ve_after_eol_3.dump b/src/testdir/dumps/Test_conceal_ve_after_eol_3.dump
new file mode 100644
index 0000000000..5eff9fa04e
--- /dev/null
+++ b/src/testdir/dumps/Test_conceal_ve_after_eol_3.dump
@@ -0,0 +1,3 @@
+|a+0&#ffffff0|b|c|d|e|f|g|h|i|j|k|l|m|n|p|o|p| > @56
+|~+0#4040ff13&| @73
+| +0#0000000&@56|1|,|2|6|-|2|7| @6|A|l@1|
diff --git a/src/testdir/dumps/Test_conceal_ve_after_eol_4.dump b/src/testdir/dumps/Test_conceal_ve_after_eol_4.dump
new file mode 100644
index 0000000000..0b2120a185
--- /dev/null
+++ b/src/testdir/dumps/Test_conceal_ve_after_eol_4.dump
@@ -0,0 +1,3 @@
+|a+0&#ffffff0|b|c|d|e|f|g|h|i|j|k|l|m|n|p|o|p| @1> @55
+|~+0#4040ff13&| @73
+| +0#0000000&@56|1|,|2|6|-|2|8| @6|A|l@1|
diff --git a/src/testdir/dumps/Test_conceal_ve_after_eol_5.dump b/src/testdir/dumps/Test_conceal_ve_after_eol_5.dump
new file mode 100644
index 0000000000..2aa86446cf
--- /dev/null
+++ b/src/testdir/dumps/Test_conceal_ve_after_eol_5.dump
@@ -0,0 +1,3 @@
+|a+0&#ffffff0|b|c|d|e|f|g|h|i|j|k|l|m|n|p|o|p| @1>r| @54
+|~+0#4040ff13&| @73
+| +0#0000000&@56|1|,|2|8| @9|A|l@1|
diff --git a/src/testdir/dumps/Test_conceal_ve_after_eol_rl_1.dump b/src/testdir/dumps/Test_conceal_ve_after_eol_rl_1.dump
new file mode 100644
index 0000000000..840e19b178
--- /dev/null
+++ b/src/testdir/dumps/Test_conceal_ve_after_eol_rl_1.dump
@@ -0,0 +1,3 @@
+| +0&#ffffff0@57>p|o|p|n|m|l|k|j|i|h|g|f|e|d|c|b|a
+| +0#4040ff13&@73|~
+| +0#0000000&@56|1|,|2|5| @9|A|l@1|
diff --git a/src/testdir/dumps/Test_conceal_ve_after_eol_rl_2.dump b/src/testdir/dumps/Test_conceal_ve_after_eol_rl_2.dump
new file mode 100644
index 0000000000..c4b0190508
--- /dev/null
+++ b/src/testdir/dumps/Test_conceal_ve_after_eol_rl_2.dump
@@ -0,0 +1,3 @@
+| +0&#ffffff0@56> |p|o|p|n|m|l|k|j|i|h|g|f|e|d|c|b|a
+| +0#4040ff13&@73|~
+| +0#0000000&@56|1|,|2|6| @9|A|l@1|
diff --git a/src/testdir/dumps/Test_conceal_ve_after_eol_rl_3.dump b/src/testdir/dumps/Test_conceal_ve_after_eol_rl_3.dump
new file mode 100644
index 0000000000..e4a05f7237
--- /dev/null
+++ b/src/testdir/dumps/Test_conceal_ve_after_eol_rl_3.dump
@@ -0,0 +1,3 @@
+| +0&#ffffff0@55> @1|p|o|p|n|m|l|k|j|i|h|g|f|e|d|c|b|a
+| +0#4040ff13&@73|~
+| +0#0000000&@56|1|,|2|6|-|2|7| @6|A|l@1|
diff --git a/src/testdir/dumps/Test_conceal_ve_after_eol_rl_4.dump b/src/testdir/dumps/Test_conceal_ve_after_eol_rl_4.dump
new file mode 100644
index 0000000000..9f21657dbe
--- /dev/null
+++ b/src/testdir/dumps/Test_conceal_ve_after_eol_rl_4.dump
@@ -0,0 +1,3 @@
+| +0&#ffffff0@54> @2|p|o|p|n|m|l|k|j|i|h|g|f|e|d|c|b|a
+| +0#4040ff13&@73|~
+| +0#0000000&@56|1|,|2|6|-|2|8| @6|A|l@1|
diff --git a/src/testdir/dumps/Test_conceal_ve_after_eol_rl_5.dump b/src/testdir/dumps/Test_conceal_ve_after_eol_rl_5.dump
new file mode 100644
index 0000000000..7d2dad660d
--- /dev/null
+++ b/src/testdir/dumps/Test_conceal_ve_after_eol_rl_5.dump
@@ -0,0 +1,3 @@
+| +0&#ffffff0@54>r| @1|p|o|p|n|m|l|k|j|i|h|g|f|e|d|c|b|a
+| +0#4040ff13&@73|~
+| +0#0000000&@56|1|,|2|8| @9|A|l@1|
diff --git a/src/testdir/test_conceal.vim b/src/testdir/test_conceal.vim
index 16953fc32c..7080fdd1f0 100644
--- a/src/testdir/test_conceal.vim
+++ b/src/testdir/test_conceal.vim
@@ -462,4 +462,58 @@ func Test_conceal_mouse_click()
set mouse& virtualedit&
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]
+ call setline(1, 'abcdefgh|hidden|ijklmnpop')
+ syntax match test /|hidden|/ conceal
+ set conceallevel=2 concealcursor=n virtualedit=all
+ normal! $
+ [CODE]
+ call writefile(code, 'XTest_conceal_ve_after_eol', 'D')
+ let buf = RunVimInTerminal('-S XTest_conceal_ve_after_eol', {'rows': 3})
+ call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_1', {})
+ call term_sendkeys(buf, "l")
+ call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_2', {})
+ call term_sendkeys(buf, "l")
+ call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_3', {})
+ call term_sendkeys(buf, "l")
+ call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_4', {})
+ call term_sendkeys(buf, "rr")
+ call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_5', {})
+
+ " clean up
+ call StopVimInTerminal(buf)
+endfunc
+
+" Same as Test_conceal_virtualedit_after_eol(), but with 'rightleft' set.
+func Test_conceal_virtualedit_after_eol_rightleft()
+ CheckFeature rightleft
+ CheckScreendump
+
+ let code =<< trim [CODE]
+ call setline(1, 'abcdefgh|hidden|ijklmnpop')
+ syntax match test /|hidden|/ conceal
+ set conceallevel=2 concealcursor=n virtualedit=all rightleft
+ normal! $
+ [CODE]
+ call writefile(code, 'XTest_conceal_ve_after_eol_rl', 'D')
+ let buf = RunVimInTerminal('-S XTest_conceal_ve_after_eol_rl', {'rows': 3})
+ call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_rl_1', {})
+ call term_sendkeys(buf, "h")
+ call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_rl_2', {})
+ call term_sendkeys(buf, "h")
+ call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_rl_3', {})
+ call term_sendkeys(buf, "h")
+ call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_rl_4', {})
+ call term_sendkeys(buf, "rr")
+ call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_rl_5', {})
+
+ " clean up
+ call StopVimInTerminal(buf)
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index fadecf4462..6bdf896957 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 */
/**/
+ 176,
+/**/
175,
/**/
174,