Skip to content

Commit 9352c28

Browse files
zeertzjqchrisbra
authored andcommitted
patch 9.1.0179: 'wincolor' highlight missing with "below" virtual text
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>
1 parent 45da329 commit 9352c28

11 files changed

Lines changed: 129 additions & 9 deletions

src/drawline.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -812,12 +812,12 @@ text_prop_position(
812812
*p_extra = l;
813813
*n_extra = n_used + before + after + padding;
814814
*n_attr = mb_charlen(*p_extra);
815-
if (above)
816-
*n_attr -= padding + after;
817-
818815
// n_attr_skip will not be decremented before draw_state is
819816
// WL_LINE
820817
*n_attr_skip = before + (padding > 0 ? padding : 0);
818+
*n_attr -= *n_attr_skip;
819+
if (above)
820+
*n_attr -= after;
821821
}
822822
}
823823
}
@@ -946,14 +946,15 @@ draw_screen_line(win_T *wp, winlinevars_T *wlv)
946946
VCOL_HLC, &wlv->color_cols);
947947

948948
int attr = wlv->win_attr;
949-
if (wp->w_p_cuc && VCOL_HLC == (long)wp->w_virtcol)
950-
attr = HL_ATTR(HLF_CUC);
951-
else if (wlv->draw_color_col && VCOL_HLC == *wlv->color_cols)
952-
attr = HL_ATTR(HLF_MC);
953949
# ifdef LINE_ATTR
954-
else if (wlv->line_attr != 0)
955-
attr = wlv->line_attr;
950+
if (wlv->line_attr != 0)
951+
attr = hl_combine_attr(attr, wlv->line_attr);
956952
# endif
953+
if (wp->w_p_cuc && VCOL_HLC == (long)wp->w_virtcol
954+
&& wlv->lnum != wp->w_cursor.lnum)
955+
attr = hl_combine_attr(attr, HL_ATTR(HLF_CUC));
956+
else if (wlv->draw_color_col && VCOL_HLC == *wlv->color_cols)
957+
attr = hl_combine_attr(attr, HL_ATTR(HLF_MC));
957958
ScreenAttrs[wlv->off++] = attr;
958959

959960
if (VCOL_HLC >= rightmost_vcol
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
>s+0&#ffd7ff255|o|m|e| |t|e|x|t| |h|e|r|e| @45
2+
@3|B+0&#5fd7ff255|E|L|O|W| +0&#ffd7ff255@51
3+
|s|o|m|e| |m|u|c|h| |l|o|n|g|e|r| |t|e|x|t| |h|e|r|e| @33
4+
|m|o|r|e| |t|e|x|t| |h|e|r|e| @2|A+0&#ffff4012|F|T|E|R| +0&#ffd7ff255@37
5+
|~+0#4040ff13&| @58
6+
|~| @58
7+
|~| @58
8+
|:+0#0000000#ffffff0| @40|1|,|1| @10|A|l@1|
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
>s+8&#ffd7ff255|o|m|e| |t|e|x|t| |h|e|r|e| @45
2+
@3|B+8&#5fd7ff255|E|L|O|W| +8&#ffd7ff255@51
3+
|s+0&&|o|m|e| |m|u|c|h| |l|o|n|g|e|r| |t|e|x|t| |h|e|r|e| @33
4+
|m|o|r|e| |t|e|x|t| |h|e|r|e| @2|A+0&#ffff4012|F|T|E|R| +0&#ffd7ff255@37
5+
|~+0#4040ff13&| @58
6+
|~| @58
7+
|~| @58
8+
|:+0#0000000#ffffff0| @40|1|,|1| @10|A|l@1|
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
>s+8&#ffd7ff255|o|m|e| |t|e|x|t| |h|e|r|e| @14| +8&#ffd7d7255| +8&#ffd7ff255@29
2+
@3|B+8&#5fd7ff255|E|L|O|W| +8&#ffd7ff255@51
3+
|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
4+
|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
5+
|~+0#4040ff13&| @58
6+
|~| @58
7+
|~| @58
8+
|:+0#0000000#ffffff0| @40|1|,|1| @10|A|l@1|
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
>s+8&#af5f00255|o|m|e| |t|e|x|t| |h|e|r|e| @14| +8&#ffd7d7255| +8&#af5f00255@29
2+
@3|B+8&#5fd7ff255|E|L|O|W| +8&#af5f00255@51
3+
|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
4+
|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
5+
|~+0#4040ff13&| @58
6+
|~| @58
7+
|~| @58
8+
|:+0#0000000#ffffff0| @40|1|,|1| @10|A|l@1|
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
|s+8&#af5f00255|o|m|e| |t|e|x|t| |h|e|r>e| @14| +8&#ffd7d7255| +8&#af5f00255@29
2+
@3|B+8&#5fd7ff255|E|L|O|W| +8&#af5f00255@51
3+
|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
4+
|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
5+
|~+0#4040ff13&| @58
6+
|~| @58
7+
|~| @58
8+
|:+0#0000000#ffffff0| @40|1|,|1|4| @9|A|l@1|
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
|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
2+
@3|B+0&#5fd7ff255|E|L|O|W| +0&#ffd7ff255@51
3+
|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
4+
|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
5+
|~+0#4040ff13&| @58
6+
|~| @58
7+
|~| @58
8+
|:+0#0000000#ffffff0| @40|2|,|2|6| @9|A|l@1|
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
|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
2+
@3|B+0&#5fd7ff255|E|L|O|W| +0&#ffd7ff255@51
3+
|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
4+
|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
5+
|~+0#4040ff13&| @58
6+
|~| @58
7+
|~| @58
8+
|:+0#0000000#ffffff0| @40|2|,|2|7| @9|A|l@1|
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
|s+8&#af5f00255|o|m|e| |t|e|x|t| |h|e|r|e| @11> @2| +8&#ffd7d7255| +8&#af5f00255@29
2+
@3|B+8&#5fd7ff255|E|L|O|W| +8&#af5f00255@51
3+
|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
4+
|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
5+
|~+0#4040ff13&| @58
6+
|~| @58
7+
|~| @58
8+
|:+0#0000000#ffffff0| @40|1|,|1|5|-|2|7| @6|A|l@1|

src/testdir/test_textprop.vim

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4485,4 +4485,57 @@ func Test_textprop_backspace_fo_aw()
44854485
call prop_type_delete('test')
44864486
endfunc
44874487

4488+
func Test_textprop_with_wincolor()
4489+
CheckRunVimInTerminal
4490+
4491+
let lines =<< trim END
4492+
call setline(1, 'some text here')
4493+
call setline(2, 'some much longer text here')
4494+
call setline(3, 'more text here')
4495+
call prop_type_add('afterprop', #{highlight: 'Search'})
4496+
call prop_type_add('belowprop', #{highlight: 'DiffAdd'})
4497+
call prop_add(3, 0, #{type: 'afterprop', text: 'AFTER',
4498+
\ text_align: 'after', text_padding_left: 3})
4499+
call prop_add(1, 0, #{type: 'belowprop', text: 'BELOW',
4500+
\ text_align: 'below', text_padding_left: 3})
4501+
set wincolor=DiffChange wrap
4502+
END
4503+
call writefile(lines, 'XtextPropWincolor', 'D')
4504+
let buf = RunVimInTerminal('-S XtextPropWincolor', #{rows: 8, cols: 60})
4505+
4506+
call term_sendkeys(buf, ":\<CR>")
4507+
call VerifyScreenDump(buf, 'Test_prop_wincolor_1', {})
4508+
4509+
call term_sendkeys(buf, ":set cursorline\<CR>:\<CR>")
4510+
call VerifyScreenDump(buf, 'Test_prop_wincolor_2', {})
4511+
4512+
call term_sendkeys(buf, ":set nowrap\<CR>:\<CR>")
4513+
call VerifyScreenDump(buf, 'Test_prop_wincolor_2', {})
4514+
4515+
call term_sendkeys(buf, ":set nocursorline\<CR>:\<CR>")
4516+
call VerifyScreenDump(buf, 'Test_prop_wincolor_1', {})
4517+
4518+
call term_sendkeys(buf, ":set cursorline colorcolumn=30\<CR>:\<CR>")
4519+
call VerifyScreenDump(buf, 'Test_prop_wincolor_3', {})
4520+
4521+
call term_sendkeys(buf, ":hi CursorLine ctermbg=Brown\<CR>:\<CR>")
4522+
call VerifyScreenDump(buf, 'Test_prop_wincolor_4', {})
4523+
4524+
call term_sendkeys(buf, ":set cursorcolumn\<CR>:\<CR>")
4525+
call term_sendkeys(buf, '$')
4526+
call VerifyScreenDump(buf, 'Test_prop_wincolor_5', {})
4527+
4528+
call term_sendkeys(buf, 'j')
4529+
call VerifyScreenDump(buf, 'Test_prop_wincolor_6', {})
4530+
4531+
call term_sendkeys(buf, ":set virtualedit=all\<CR>:\<CR>")
4532+
call term_sendkeys(buf, 'l')
4533+
call VerifyScreenDump(buf, 'Test_prop_wincolor_7', {})
4534+
4535+
call term_sendkeys(buf, 'k')
4536+
call VerifyScreenDump(buf, 'Test_prop_wincolor_8', {})
4537+
4538+
call StopVimInTerminal(buf)
4539+
endfunc
4540+
44884541
" vim: shiftwidth=2 sts=2 expandtab

0 commit comments

Comments
 (0)