summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-03-14 18:16:56 +0100
committerChristian Brabandt <cb@256bit.org>2024-03-14 18:16:56 +0100
commit9352c282928f6cb25060249c157a28803c6efa9d (patch)
tree55dd90efca27d18b07089815c19b368d8b118efb
parent45da32964d6e7e635af8fcf0b42e974b0b536ed3 (diff)
patch 9.1.0179: 'wincolor' highlight missing with "below" virtual textv9.1.0179
Problem: 'wincolor' highlight missing with "below" virtual text. Solution: Subtract n_attr_skip from n_attr. Combine 'wincolor' with other highlights when 'nowrap' is set. (zeertzjq) closes: #14196 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
-rw-r--r--src/drawline.c19
-rw-r--r--src/testdir/dumps/Test_prop_wincolor_1.dump8
-rw-r--r--src/testdir/dumps/Test_prop_wincolor_2.dump8
-rw-r--r--src/testdir/dumps/Test_prop_wincolor_3.dump8
-rw-r--r--src/testdir/dumps/Test_prop_wincolor_4.dump8
-rw-r--r--src/testdir/dumps/Test_prop_wincolor_5.dump8
-rw-r--r--src/testdir/dumps/Test_prop_wincolor_6.dump8
-rw-r--r--src/testdir/dumps/Test_prop_wincolor_7.dump8
-rw-r--r--src/testdir/dumps/Test_prop_wincolor_8.dump8
-rw-r--r--src/testdir/test_textprop.vim53
-rw-r--r--src/version.c2
11 files changed, 129 insertions, 9 deletions
diff --git a/src/drawline.c b/src/drawline.c
index 088477faf0..112dc6466a 100644
--- a/src/drawline.c
+++ b/src/drawline.c
@@ -812,12 +812,12 @@ text_prop_position(
*p_extra = l;
*n_extra = n_used + before + after + padding;
*n_attr = mb_charlen(*p_extra);
- if (above)
- *n_attr -= padding + after;
-
// n_attr_skip will not be decremented before draw_state is
// WL_LINE
*n_attr_skip = before + (padding > 0 ? padding : 0);
+ *n_attr -= *n_attr_skip;
+ if (above)
+ *n_attr -= after;
}
}
}
@@ -946,14 +946,15 @@ draw_screen_line(win_T *wp, winlinevars_T *wlv)
VCOL_HLC, &wlv->color_cols);
int attr = wlv->win_attr;
- if (wp->w_p_cuc && VCOL_HLC == (long)wp->w_virtcol)
- attr = HL_ATTR(HLF_CUC);
- else if (wlv->draw_color_col && VCOL_HLC == *wlv->color_cols)
- attr = HL_ATTR(HLF_MC);
# ifdef LINE_ATTR
- else if (wlv->line_attr != 0)
- attr = wlv->line_attr;
+ if (wlv->line_attr != 0)
+ attr = hl_combine_attr(attr, wlv->line_attr);
# endif
+ if (wp->w_p_cuc && VCOL_HLC == (long)wp->w_virtcol
+ && wlv->lnum != wp->w_cursor.lnum)
+ attr = hl_combine_attr(attr, HL_ATTR(HLF_CUC));
+ else if (wlv->draw_color_col && VCOL_HLC == *wlv->color_cols)
+ attr = hl_combine_attr(attr, HL_ATTR(HLF_MC));
ScreenAttrs[wlv->off++] = attr;
if (VCOL_HLC >= rightmost_vcol
diff --git a/src/testdir/dumps/Test_prop_wincolor_1.dump b/src/testdir/dumps/Test_prop_wincolor_1.dump
new file mode 100644
index 0000000000..d8a6226359
--- /dev/null
+++ b/src/testdir/dumps/Test_prop_wincolor_1.dump
@@ -0,0 +1,8 @@
+>s+0&#ffd7ff255|o|m|e| |t|e|x|t| |h|e|r|e| @45
+@3|B+0&#5fd7ff255|E|L|O|W| +0&#ffd7ff255@51
+|s|o|m|e| |m|u|c|h| |l|o|n|g|e|r| |t|e|x|t| |h|e|r|e| @33
+|m|o|r|e| |t|e|x|t| |h|e|r|e| @2|A+0&#ffff4012|F|T|E|R| +0&#ffd7ff255@37
+|~+0#4040ff13&| @58
+|~| @58
+|~| @58
+|:+0#0000000#ffffff0| @40|1|,|1| @10|A|l@1|
diff --git a/src/testdir/dumps/Test_prop_wincolor_2.dump b/src/testdir/dumps/Test_prop_wincolor_2.dump
new file mode 100644
index 0000000000..6e5126c476
--- /dev/null
+++ b/src/testdir/dumps/Test_prop_wincolor_2.dump
@@ -0,0 +1,8 @@
+>s+8&#ffd7ff255|o|m|e| |t|e|x|t| |h|e|r|e| @45
+@3|B+8&#5fd7ff255|E|L|O|W| +8&#ffd7ff255@51
+|s+0&&|o|m|e| |m|u|c|h| |l|o|n|g|e|r| |t|e|x|t| |h|e|r|e| @33
+|m|o|r|e| |t|e|x|t| |h|e|r|e| @2|A+0&#ffff4012|F|T|E|R| +0&#ffd7ff255@37
+|~+0#4040ff13&| @58
+|~| @58
+|~| @58
+|:+0#0000000#ffffff0| @40|1|,|1| @10|A|l@1|
diff --git a/src/testdir/dumps/Test_prop_wincolor_3.dump b/src/testdir/dumps/Test_prop_wincolor_3.dump
new file mode 100644
index 0000000000..f77c27422e
--- /dev/null
+++ b/src/testdir/dumps/Test_prop_wincolor_3.dump
@@ -0,0 +1,8 @@
+>s+8&#ffd7ff255|o|m|e| |t|e|x|t| |h|e|r|e| @14| +8&#ffd7d7255| +8&#ffd7ff255@29
+@3|B+8&#5fd7ff255|E|L|O|W| +8&#ffd7ff255@51
+|s+0&&|o|m|e| |m|u|c|h| |l|o|n|g|e|r| |t|e|x|t| |h|e|r|e| @2| +0&#ffd7d7255| +0&#ffd7ff255@29
+|m|o|r|e| |t|e|x|t| |h|e|r|e| @2|A+0&#ffff4012|F|T|E|R| +0&#ffd7ff255@6| +0&#ffd7d7255| +0&#ffd7ff255@29
+|~+0#4040ff13&| @58
+|~| @58
+|~| @58
+|:+0#0000000#ffffff0| @40|1|,|1| @10|A|l@1|
diff --git a/src/testdir/dumps/Test_prop_wincolor_4.dump b/src/testdir/dumps/Test_prop_wincolor_4.dump
new file mode 100644
index 0000000000..06d6b0f41d
--- /dev/null
+++ b/src/testdir/dumps/Test_prop_wincolor_4.dump
@@ -0,0 +1,8 @@
+>s+8&#af5f00255|o|m|e| |t|e|x|t| |h|e|r|e| @14| +8&#ffd7d7255| +8&#af5f00255@29
+@3|B+8&#5fd7ff255|E|L|O|W| +8&#af5f00255@51
+|s+0&#ffd7ff255|o|m|e| |m|u|c|h| |l|o|n|g|e|r| |t|e|x|t| |h|e|r|e| @2| +0&#ffd7d7255| +0&#ffd7ff255@29
+|m|o|r|e| |t|e|x|t| |h|e|r|e| @2|A+0&#ffff4012|F|T|E|R| +0&#ffd7ff255@6| +0&#ffd7d7255| +0&#ffd7ff255@29
+|~+0#4040ff13&| @58
+|~| @58
+|~| @58
+|:+0#0000000#ffffff0| @40|1|,|1| @10|A|l@1|
diff --git a/src/testdir/dumps/Test_prop_wincolor_5.dump b/src/testdir/dumps/Test_prop_wincolor_5.dump
new file mode 100644
index 0000000000..0c062b4452
--- /dev/null
+++ b/src/testdir/dumps/Test_prop_wincolor_5.dump
@@ -0,0 +1,8 @@
+|s+8&#af5f00255|o|m|e| |t|e|x|t| |h|e|r>e| @14| +8&#ffd7d7255| +8&#af5f00255@29
+@3|B+8&#5fd7ff255|E|L|O|W| +8&#af5f00255@51
+|s+0&#ffd7ff255|o|m|e| |m|u|c|h| |l|o|n|g+0&#e0e0e08|e+0&#ffd7ff255|r| |t|e|x|t| |h|e|r|e| @2| +0&#ffd7d7255| +0&#ffd7ff255@29
+|m|o|r|e| |t|e|x|t| |h|e|r|e+0&#e0e0e08| +0&#ffd7ff255@2|A+0&#ffff4012|F|T|E|R| +0&#ffd7ff255@6| +0&#ffd7d7255| +0&#ffd7ff255@29
+|~+0#4040ff13&| @58
+|~| @58
+|~| @58
+|:+0#0000000#ffffff0| @40|1|,|1|4| @9|A|l@1|
diff --git a/src/testdir/dumps/Test_prop_wincolor_6.dump b/src/testdir/dumps/Test_prop_wincolor_6.dump
new file mode 100644
index 0000000000..e07b3e6f79
--- /dev/null
+++ b/src/testdir/dumps/Test_prop_wincolor_6.dump
@@ -0,0 +1,8 @@
+|s+0&#ffd7ff255|o|m|e| |t|e|x|t| |h|e|r|e| @10| +0&#e0e0e08| +0&#ffd7ff255@2| +0&#ffd7d7255| +0&#ffd7ff255@29
+@3|B+0&#5fd7ff255|E|L|O|W| +0&#ffd7ff255@51
+|s+8&#af5f00255|o|m|e| |m|u|c|h| |l|o|n|g|e|r| |t|e|x|t| |h|e|r>e| @2| +8&#ffd7d7255| +8&#af5f00255@29
+|m+0&#ffd7ff255|o|r|e| |t|e|x|t| |h|e|r|e| @2|A+0&#ffff4012|F|T|E|R| +0&#ffd7ff255@2| +0&#e0e0e08| +0&#ffd7ff255@2| +0&#ffd7d7255| +0&#ffd7ff255@29
+|~+0#4040ff13&| @58
+|~| @58
+|~| @58
+|:+0#0000000#ffffff0| @40|2|,|2|6| @9|A|l@1|
diff --git a/src/testdir/dumps/Test_prop_wincolor_7.dump b/src/testdir/dumps/Test_prop_wincolor_7.dump
new file mode 100644
index 0000000000..941281104a
--- /dev/null
+++ b/src/testdir/dumps/Test_prop_wincolor_7.dump
@@ -0,0 +1,8 @@
+|s+0&#ffd7ff255|o|m|e| |t|e|x|t| |h|e|r|e| @11| +0&#e0e0e08| +0&#ffd7ff255@1| +0&#ffd7d7255| +0&#ffd7ff255@29
+@3|B+0&#5fd7ff255|E|L|O|W| +0&#ffd7ff255@51
+|s+8&#af5f00255|o|m|e| |m|u|c|h| |l|o|n|g|e|r| |t|e|x|t| |h|e|r|e> @2| +8&#ffd7d7255| +8&#af5f00255@29
+|m+0&#ffd7ff255|o|r|e| |t|e|x|t| |h|e|r|e| @2|A+0&#ffff4012|F|T|E|R| +0&#ffd7ff255@3| +0&#e0e0e08| +0&#ffd7ff255@1| +0&#ffd7d7255| +0&#ffd7ff255@29
+|~+0#4040ff13&| @58
+|~| @58
+|~| @58
+|:+0#0000000#ffffff0| @40|2|,|2|7| @9|A|l@1|
diff --git a/src/testdir/dumps/Test_prop_wincolor_8.dump b/src/testdir/dumps/Test_prop_wincolor_8.dump
new file mode 100644
index 0000000000..9df69ec9e7
--- /dev/null
+++ b/src/testdir/dumps/Test_prop_wincolor_8.dump
@@ -0,0 +1,8 @@
+|s+8&#af5f00255|o|m|e| |t|e|x|t| |h|e|r|e| @11> @2| +8&#ffd7d7255| +8&#af5f00255@29
+@3|B+8&#5fd7ff255|E|L|O|W| +8&#af5f00255@51
+|s+0&#ffd7ff255|o|m|e| |m|u|c|h| |l|o|n|g|e|r| |t|e|x|t| |h|e|r|e| +0&#e0e0e08| +0&#ffd7ff255@1| +0&#ffd7d7255| +0&#ffd7ff255@29
+|m|o|r|e| |t|e|x|t| |h|e|r|e| @2|A+0&#ffff4012|F|T|E|R| +0&#ffd7ff255@3| +0&#e0e0e08| +0&#ffd7ff255@1| +0&#ffd7d7255| +0&#ffd7ff255@29
+|~+0#4040ff13&| @58
+|~| @58
+|~| @58
+|:+0#0000000#ffffff0| @40|1|,|1|5|-|2|7| @6|A|l@1|
diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim
index 1074b0ca54..993a64d3bb 100644
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -4485,4 +4485,57 @@ func Test_textprop_backspace_fo_aw()
call prop_type_delete('test')
endfunc
+func Test_textprop_with_wincolor()
+ CheckRunVimInTerminal
+
+ let lines =<< trim END
+ call setline(1, 'some text here')
+ call setline(2, 'some much longer text here')
+ call setline(3, 'more text here')
+ call prop_type_add('afterprop', #{highlight: 'Search'})
+ call prop_type_add('belowprop', #{highlight: 'DiffAdd'})
+ call prop_add(3, 0, #{type: 'afterprop', text: 'AFTER',
+ \ text_align: 'after', text_padding_left: 3})
+ call prop_add(1, 0, #{type: 'belowprop', text: 'BELOW',
+ \ text_align: 'below', text_padding_left: 3})
+ set wincolor=DiffChange wrap
+ END
+ call writefile(lines, 'XtextPropWincolor', 'D')
+ let buf = RunVimInTerminal('-S XtextPropWincolor', #{rows: 8, cols: 60})
+
+ call term_sendkeys(buf, ":\<CR>")
+ call VerifyScreenDump(buf, 'Test_prop_wincolor_1', {})
+
+ call term_sendkeys(buf, ":set cursorline\<CR>:\<CR>")
+ call VerifyScreenDump(buf, 'Test_prop_wincolor_2', {})
+
+ call term_sendkeys(buf, ":set nowrap\<CR>:\<CR>")
+ call VerifyScreenDump(buf, 'Test_prop_wincolor_2', {})
+
+ call term_sendkeys(buf, ":set nocursorline\<CR>:\<CR>")
+ call VerifyScreenDump(buf, 'Test_prop_wincolor_1', {})
+
+ call term_sendkeys(buf, ":set cursorline colorcolumn=30\<CR>:\<CR>")
+ call VerifyScreenDump(buf, 'Test_prop_wincolor_3', {})
+
+ call term_sendkeys(buf, ":hi CursorLine ctermbg=Brown\<CR>:\<CR>")
+ call VerifyScreenDump(buf, 'Test_prop_wincolor_4', {})
+
+ call term_sendkeys(buf, ":set cursorcolumn\<CR>:\<CR>")
+ call term_sendkeys(buf, '$')
+ call VerifyScreenDump(buf, 'Test_prop_wincolor_5', {})
+
+ call term_sendkeys(buf, 'j')
+ call VerifyScreenDump(buf, 'Test_prop_wincolor_6', {})
+
+ call term_sendkeys(buf, ":set virtualedit=all\<CR>:\<CR>")
+ call term_sendkeys(buf, 'l')
+ call VerifyScreenDump(buf, 'Test_prop_wincolor_7', {})
+
+ call term_sendkeys(buf, 'k')
+ call VerifyScreenDump(buf, 'Test_prop_wincolor_8', {})
+
+ call StopVimInTerminal(buf)
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index 1e2efcb86e..80dc66709a 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 */
/**/
+ 179,
+/**/
178,
/**/
177,