patch 9.1.0174: 'cursorline' and 'wincolor' hl missing with conceal and wrap

Commit: 
https://github.com/vim/vim/commit/21b0a3df8c4abb884489dfcc0c92b1bbe058f291
Author: zeertzjq <zeert...@outlook.com>
Date:   Wed Mar 13 20:06:34 2024 +0100

    patch 9.1.0174: 'cursorline' and 'wincolor' hl missing with conceal and wrap
    
    Problem:  'cursorline' and 'wincolor' highlight missing with concealed and
              wrapped lines.
    Solution: Apply 'cursorline' and 'wincolor' highlight to boguscols.
              (zeertzjq)
    
    Since 'cursorline' and 'wincolor' highlight apply after the end of the
    line, it is more consistent to have them also apply to boguscols.
    
    Assigning MAXCOL to values in ScreenCols[] make mouse click behave the
    same with 'cursorline' and 'nocursorline', but such behavior may be
    incorrect, as it puts the cursor on the next screen line.  That may be
    fixed in a future PR.
    
    closes: #14192
    
    Signed-off-by: zeertzjq <zeert...@outlook.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/drawline.c b/src/drawline.c
index 629d66f1c..946e9bd3d 100644
--- a/src/drawline.c
+++ b/src/drawline.c
@@ -4121,6 +4121,47 @@ win_line(
        {
 #ifdef FEAT_CONCEAL
            wlv.col -= wlv.boguscols;
+           // Apply 'cursorline' and 'wincolor' highlight.
+           if (wlv.boguscols != 0 && (
+# ifdef LINE_ATTR
+                       wlv.line_attr != 0 ||
+# endif
+                       wlv.win_attr != 0
+                       )
+              )
+           {
+               int attr = wlv.win_attr;
+# ifdef LINE_ATTR
+               if (wlv.line_attr != 0)
+                   attr = hl_combine_attr(attr, wlv.line_attr);
+# endif
+               while ((
+# ifdef FEAT_RIGHTLEFT
+                           wp->w_p_rl ? wlv.col >= 0 :
+# endif
+                           wlv.col < wp->w_width))
+               {
+                   ScreenLines[wlv.off] = ' ';
+                   if (enc_utf8)
+                       ScreenLinesUC[wlv.off] = 0;
+                   ScreenAttrs[wlv.off] = attr;
+                   ScreenCols[wlv.off] = MAXCOL;  // TODO: this is wrong
+# ifdef FEAT_RIGHTLEFT
+                   if (wp->w_p_rl)
+                   {
+                       wlv.off--;
+                       wlv.col--;
+                       wlv.boguscols++;
+                   }
+                   else
+# endif
+                   {
+                       wlv.off++;
+                       wlv.col++;
+                       wlv.boguscols--;
+                   }
+               }
+           }
            wlv_screen_line(wp, &wlv, FALSE);
            wlv.col += wlv.boguscols;
            wlv.boguscols = 0;
diff --git a/src/testdir/dumps/Test_conceal_cul_wcr_01.dump 
b/src/testdir/dumps/Test_conceal_cul_wcr_01.dump
new file mode 100644
index 000000000..9cb27c8e9
--- /dev/null
+++ b/src/testdir/dumps/Test_conceal_cul_wcr_01.dump
@@ -0,0 +1,4 @@
+|o+8&#ffffff0|n|e| |o|n|e| |o|n|e| @1|o|n|e| |o|n|e| |o|n|e| |o|n|e| |o|n>e| @7
+@1|o|n|e| |o|n|e| |o|n|e| @27
+|~+0#4040ff13&| @38
+| +0#0000000&@21|1|,|4|0| @9|A|l@1| 
diff --git a/src/testdir/dumps/Test_conceal_cul_wcr_02.dump 
b/src/testdir/dumps/Test_conceal_cul_wcr_02.dump
new file mode 100644
index 000000000..668e1af84
--- /dev/null
+++ b/src/testdir/dumps/Test_conceal_cul_wcr_02.dump
@@ -0,0 +1,4 @@
+|o+8#ffffff16#e000002|n|e| |o|n|e| |o|n|e| @1|o|n|e| |o|n|e| |o|n|e| |o|n|e| 
|o|n>e| @7
+@1|o|n|e| |o|n|e| |o|n|e| @27
+|~+0#4040ff13&| @38
+|:+0#0000000#ffffff0|s|e|t| |w|i|n|c|o|l|o|r|=|E|r@1|o|r|M|s|g|1|,|4|0| 
@9|A|l@1| 
diff --git a/src/testdir/dumps/Test_conceal_cul_wcr_03.dump 
b/src/testdir/dumps/Test_conceal_cul_wcr_03.dump
new file mode 100644
index 000000000..965e9f577
--- /dev/null
+++ b/src/testdir/dumps/Test_conceal_cul_wcr_03.dump
@@ -0,0 +1,4 @@
+|o+0#ffffff16#e000002|n|e| |o|n|e| |o|n|e| @1|o|n|e| |o|n|e| |o|n|e| |o|n|e| 
|o|n>e| @7
+@1|o|n|e| |o|n|e| |o|n|e| @27
+|~+0#4040ff13&| @38
+|:+0#0000000#ffffff0|s|e|t| |n|o|c|u|r|s|o|r|l|i|n|e| @4|1|,|4|0| @9|A|l@1| 
diff --git a/src/testdir/dumps/Test_conceal_cul_wcr_rl_01.dump 
b/src/testdir/dumps/Test_conceal_cul_wcr_rl_01.dump
new file mode 100644
index 000000000..d1a31a6aa
--- /dev/null
+++ b/src/testdir/dumps/Test_conceal_cul_wcr_rl_01.dump
@@ -0,0 +1,4 @@
+| +8&#ffffff0@7>e|n|o| |e|n|o| |e|n|o| |e|n|o| |e|n|o| @1|e|n|o| |e|n|o| |e|n|o
+| @27|e|n|o| |e|n|o| |e|n|o| 
+| +0#4040ff13&@38|~
+| +0#0000000&@21|1|,|4|0| @9|A|l@1| 
diff --git a/src/testdir/dumps/Test_conceal_cul_wcr_rl_02.dump 
b/src/testdir/dumps/Test_conceal_cul_wcr_rl_02.dump
new file mode 100644
index 000000000..21809e940
--- /dev/null
+++ b/src/testdir/dumps/Test_conceal_cul_wcr_rl_02.dump
@@ -0,0 +1,4 @@
+| +8#ffffff16#e000002@7>e|n|o| |e|n|o| |e|n|o| |e|n|o| |e|n|o| @1|e|n|o| 
|e|n|o| |e|n|o
+| @27|e|n|o| |e|n|o| |e|n|o| 
+| +0#4040ff13&@38|~
+|:+0#0000000#ffffff0|s|e|t| |w|i|n|c|o|l|o|r|=|E|r@1|o|r|M|s|g|1|,|4|0| 
@9|A|l@1| 
diff --git a/src/testdir/dumps/Test_conceal_cul_wcr_rl_03.dump 
b/src/testdir/dumps/Test_conceal_cul_wcr_rl_03.dump
new file mode 100644
index 000000000..0eeb739f3
--- /dev/null
+++ b/src/testdir/dumps/Test_conceal_cul_wcr_rl_03.dump
@@ -0,0 +1,4 @@
+| +0#ffffff16#e000002@7>e|n|o| |e|n|o| |e|n|o| |e|n|o| |e|n|o| @1|e|n|o| 
|e|n|o| |e|n|o
+| @27|e|n|o| |e|n|o| |e|n|o| 
+| +0#4040ff13&@38|~
+|:+0#0000000#ffffff0|s|e|t| |n|o|c|u|r|s|o|r|l|i|n|e| @4|1|,|4|0| @9|A|l@1| 
diff --git a/src/testdir/test_conceal.vim b/src/testdir/test_conceal.vim
index e9779213f..16953fc32 100644
--- a/src/testdir/test_conceal.vim
+++ b/src/testdir/test_conceal.vim
@@ -171,6 +171,57 @@ func Test_conceal_with_cursorcolumn()
   call StopVimInTerminal(buf)
 endfunc
 
+" Check that 'cursorline' and 'wincolor' apply to the whole line in presence
+" of wrapped lines containing concealed text.
+func Test_conceal_wrapped_cursorline_wincolor()
+  CheckScreendump
+
+  let code =<< trim [CODE]
+    call setline(1, 'one one one |hidden| one one one one one one one one')
+    syntax match test /|hidden|/ conceal
+    set conceallevel=2 concealcursor=n cursorline
+    normal! g$
+  [CODE]
+
+  call writefile(code, 'XTest_conceal_cul_wcr', 'D')
+  let buf = RunVimInTerminal('-S XTest_conceal_cul_wcr', {'rows': 4, 'cols': 
40})
+  call VerifyScreenDump(buf, 'Test_conceal_cul_wcr_01', {})
+
+  call term_sendkeys(buf, ":set wincolor=ErrorMsg
")
+  call VerifyScreenDump(buf, 'Test_conceal_cul_wcr_02', {})
+
+  call term_sendkeys(buf, ":set nocursorline
")
+  call VerifyScreenDump(buf, 'Test_conceal_cul_wcr_03', {})
+
+  " clean up
+  call StopVimInTerminal(buf)
+endfunc
+
+" Same as Test_conceal_wrapped_cursorline_wincolor(), but with 'rightleft'.
+func Test_conceal_wrapped_cursorline_wincolor_rightleft()
+  CheckScreendump
+
+  let code =<< trim [CODE]
+    call setline(1, 'one one one |hidden| one one one one one one one one')
+    syntax match test /|hidden|/ conceal
+    set conceallevel=2 concealcursor=n cursorline rightleft
+    normal! g$
+  [CODE]
+
+  call writefile(code, 'XTest_conceal_cul_wcr_rl', 'D')
+  let buf = RunVimInTerminal('-S XTest_conceal_cul_wcr_rl', {'rows': 4, 
'cols': 40})
+  call VerifyScreenDump(buf, 'Test_conceal_cul_wcr_rl_01', {})
+
+  call term_sendkeys(buf, ":set wincolor=ErrorMsg
")
+  call VerifyScreenDump(buf, 'Test_conceal_cul_wcr_rl_02', {})
+
+  call term_sendkeys(buf, ":set nocursorline
")
+  call VerifyScreenDump(buf, 'Test_conceal_cul_wcr_rl_03', {})
+
+  " clean up
+  call StopVimInTerminal(buf)
+endfunc
+
 func Test_conceal_resize_term()
   CheckScreendump
 
diff --git a/src/version.c b/src/version.c
index 974744e60..82bd4f404 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    174,
 /**/
     173,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/E1rkU47-00HNjy-RN%40256bit.org.

Raspunde prin e-mail lui