mirror of
https://github.com/vim/vim.git
synced 2025-07-24 10:45:12 -04:00
patch 9.0.1731: blockwise Visual highlight not working with virtual text
Problem: blockwise Visual highlight not working with virtual text Solution: Reset the correct variable at the end of virtual selection and Check for double-width char inside virtual text. closes: #12606 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
This commit is contained in:
parent
8cfe52e6fb
commit
6e940d9a1d
@ -145,7 +145,8 @@ typedef struct {
|
||||
int n_attr_skip; // chars to skip before using extra_attr
|
||||
int c_extra; // extra chars, all the same
|
||||
int c_final; // final char, mandatory if set
|
||||
int extra_for_textprop; // wlv.n_extra set for textprop
|
||||
int extra_for_textprop; // n_extra set for textprop
|
||||
int start_extra_for_textprop; // extra_for_textprop was just set
|
||||
|
||||
// saved "extra" items for when draw_state becomes WL_LINE (again)
|
||||
int saved_n_extra;
|
||||
@ -1939,20 +1940,6 @@ win_line(
|
||||
|
||||
if (wlv.draw_state == WL_LINE && (area_highlighting || extra_check))
|
||||
{
|
||||
// handle Visual or match highlighting in this line
|
||||
if (wlv.vcol == wlv.fromcol
|
||||
|| (has_mbyte && wlv.vcol + 1 == wlv.fromcol
|
||||
&& wlv.n_extra == 0
|
||||
&& (*mb_ptr2cells)(ptr) > 1)
|
||||
|| ((int)vcol_prev == fromcol_prev
|
||||
&& vcol_prev < wlv.vcol // not at margin
|
||||
&& wlv.vcol < wlv.tocol))
|
||||
area_attr = vi_attr; // start highlighting
|
||||
else if (area_attr != 0
|
||||
&& (wlv.vcol == wlv.tocol
|
||||
|| (noinvcur && (colnr_T)wlv.vcol == wp->w_virtcol)))
|
||||
area_attr = 0; // stop highlighting
|
||||
|
||||
#ifdef FEAT_PROP_POPUP
|
||||
if (text_props != NULL)
|
||||
{
|
||||
@ -2131,15 +2118,10 @@ win_line(
|
||||
wlv.c_final = NUL;
|
||||
wlv.n_extra = (int)STRLEN(p);
|
||||
wlv.extra_for_textprop = TRUE;
|
||||
wlv.start_extra_for_textprop = TRUE;
|
||||
wlv.extra_attr = hl_combine_attr(wlv.win_attr,
|
||||
used_attr);
|
||||
n_attr = mb_charlen(p);
|
||||
// restore search_attr and area_attr when n_extra
|
||||
// is down to zero
|
||||
saved_search_attr = search_attr;
|
||||
saved_area_attr = area_attr;
|
||||
search_attr = 0;
|
||||
area_attr = 0;
|
||||
text_prop_attr = 0;
|
||||
text_prop_attr_comb = 0;
|
||||
if (*ptr == NUL)
|
||||
@ -2258,8 +2240,40 @@ win_line(
|
||||
// Or when not wrapping and at the rightmost column.
|
||||
text_prop_follows = TRUE;
|
||||
}
|
||||
|
||||
if (wlv.start_extra_for_textprop)
|
||||
{
|
||||
wlv.start_extra_for_textprop = FALSE;
|
||||
// restore search_attr and area_attr when n_extra
|
||||
// is down to zero
|
||||
saved_search_attr = search_attr;
|
||||
saved_area_attr = area_attr;
|
||||
search_attr = 0;
|
||||
area_attr = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int *area_attr_p =
|
||||
#ifdef FEAT_PROP_POPUP
|
||||
wlv.extra_for_textprop ? &saved_area_attr :
|
||||
#endif
|
||||
&area_attr;
|
||||
|
||||
// handle Visual or match highlighting in this line
|
||||
if (wlv.vcol == wlv.fromcol
|
||||
|| (has_mbyte && wlv.vcol + 1 == wlv.fromcol
|
||||
&& ((wlv.n_extra == 0 && (*mb_ptr2cells)(ptr) > 1)
|
||||
|| (wlv.n_extra > 0 && wlv.p_extra != NULL
|
||||
&& (*mb_ptr2cells)(wlv.p_extra) > 1)))
|
||||
|| ((int)vcol_prev == fromcol_prev
|
||||
&& vcol_prev < wlv.vcol // not at margin
|
||||
&& wlv.vcol < wlv.tocol))
|
||||
*area_attr_p = vi_attr; // start highlighting
|
||||
else if (*area_attr_p != 0
|
||||
&& (wlv.vcol == wlv.tocol
|
||||
|| (noinvcur && (colnr_T)wlv.vcol == wp->w_virtcol)))
|
||||
*area_attr_p = 0; // stop highlighting
|
||||
|
||||
#ifdef FEAT_SEARCH_EXTRA
|
||||
if (wlv.n_extra == 0)
|
||||
{
|
||||
|
@ -0,0 +1,6 @@
|
||||
>1+0&#ffffff0|2|3|4|5|6|7|8|9| @50
|
||||
|1|-+0#e000e06&|口*&|-+&|2+0#0000000&|3|4|5|6|7|8|9| @46
|
||||
|1|2|3|4|5|6|7|8|9| @50
|
||||
|~+0#4040ff13&| @58
|
||||
|~| @58
|
||||
| +0#0000000&@41|1|,|1| @10|A|l@1|
|
@ -0,0 +1,6 @@
|
||||
|1+0&#e0e0e08|2|3+0&#ffffff0|4|5|6|7|8|9| @50
|
||||
|1+0&#e0e0e08|-+0#e000e06#ffffff0|口*&|-+&|2+0#0000000&|3|4|5|6|7|8|9| @46
|
||||
|1+0&#e0e0e08>2+0&#ffffff0|3|4|5|6|7|8|9| @50
|
||||
|~+0#4040ff13&| @58
|
||||
|~| @58
|
||||
|-+2#0000000&@1| |V|I|S|U|A|L| |B|L|O|C|K| |-@1| +0&&@13|3|x|2| @6|3|,|2| @10|A|l@1|
|
@ -0,0 +1,6 @@
|
||||
|1+0&#e0e0e08|2|3|4+0&#ffffff0|5|6|7|8|9| @50
|
||||
|1+0&#e0e0e08|-+0#e000e06#ffffff0|口*&|-+&|2+0#0000000&|3|4|5|6|7|8|9| @46
|
||||
|1+0&#e0e0e08|2>3+0&#ffffff0|4|5|6|7|8|9| @50
|
||||
|~+0#4040ff13&| @58
|
||||
|~| @58
|
||||
|-+2#0000000&@1| |V|I|S|U|A|L| |B|L|O|C|K| |-@1| +0&&@13|3|x|3| @6|3|,|3| @10|A|l@1|
|
@ -0,0 +1,6 @@
|
||||
|1+0&#e0e0e08|2|3|4|5|6|7|8+0&#ffffff0|9| @50
|
||||
|1+0&#e0e0e08|-+0#e000e06#ffffff0|口*&|-+&|2+0#0000000#e0e0e08|3|4+0&#ffffff0|5|6|7|8|9| @46
|
||||
|1+0&#e0e0e08|2|3|4|5|6>7+0&#ffffff0|8|9| @50
|
||||
|~+0#4040ff13&| @58
|
||||
|~| @58
|
||||
|-+2#0000000&@1| |V|I|S|U|A|L| |B|L|O|C|K| |-@1| +0&&@13|3|x|7| @6|3|,|7| @10|A|l@1|
|
@ -0,0 +1,6 @@
|
||||
|1+0&#ffffff0|2+0&#e0e0e08|3|4|5|6|7|8+0&#ffffff0|9| @50
|
||||
|1|-+0#e000e06&|口*&|-+&|2+0#0000000#e0e0e08|3|4+0&#ffffff0|5|6|7|8|9| @46
|
||||
|1>2|3+0&#e0e0e08|4|5|6|7|8+0&#ffffff0|9| @50
|
||||
|~+0#4040ff13&| @58
|
||||
|~| @58
|
||||
|-+2#0000000&@1| |V|I|S|U|A|L| |B|L|O|C|K| |-@1| +0&&@13|3|x|6| @6|3|,|2| @10|A|l@1|
|
@ -0,0 +1,6 @@
|
||||
|1+0&#ffffff0|2|3+0&#e0e0e08|4|5|6|7|8+0&#ffffff0|9| @50
|
||||
|1|-+0#e000e06&|口*&|-+&|2+0#0000000#e0e0e08|3|4+0&#ffffff0|5|6|7|8|9| @46
|
||||
|1|2>3|4+0&#e0e0e08|5|6|7|8+0&#ffffff0|9| @50
|
||||
|~+0#4040ff13&| @58
|
||||
|~| @58
|
||||
|-+2#0000000&@1| |V|I|S|U|A|L| |B|L|O|C|K| |-@1| +0&&@13|3|x|5| @6|3|,|3| @10|A|l@1|
|
@ -0,0 +1,6 @@
|
||||
|1+0&#ffffff0|2|3|4+0&#e0e0e08|5|6|7|8+0&#ffffff0|9| @50
|
||||
|1|-+0#e000e06&|口*&|-+&|2+0#0000000#e0e0e08|3|4+0&#ffffff0|5|6|7|8|9| @46
|
||||
|1|2|3>4|5+0&#e0e0e08|6|7|8+0&#ffffff0|9| @50
|
||||
|~+0#4040ff13&| @58
|
||||
|~| @58
|
||||
|-+2#0000000&@1| |V|I|S|U|A|L| |B|L|O|C|K| |-@1| +0&&@13|3|x|4| @6|3|,|4| @10|A|l@1|
|
@ -2602,6 +2602,33 @@ func Test_prop_inserts_text_highlight()
|
||||
call StopVimInTerminal(buf)
|
||||
endfunc
|
||||
|
||||
func Test_prop_inserts_text_visual_block()
|
||||
CheckRunVimInTerminal
|
||||
|
||||
let lines =<< trim END
|
||||
call setline(1, repeat(['123456789'], 3))
|
||||
call prop_type_add('theprop', #{highlight: 'Special'})
|
||||
call prop_add(2, 2, {'type': 'theprop', 'text': '-口-'})
|
||||
END
|
||||
call writefile(lines, 'XscriptPropsVisualBlock', 'D')
|
||||
let buf = RunVimInTerminal('-S XscriptPropsVisualBlock', #{rows: 6, cols: 60})
|
||||
call VerifyScreenDump(buf, 'Test_prop_inserts_text_visual_block_1', {})
|
||||
call term_sendkeys(buf, "\<C-V>2jl")
|
||||
call VerifyScreenDump(buf, 'Test_prop_inserts_text_visual_block_2', {})
|
||||
call term_sendkeys(buf, "l")
|
||||
call VerifyScreenDump(buf, 'Test_prop_inserts_text_visual_block_3', {})
|
||||
call term_sendkeys(buf, "4l")
|
||||
call VerifyScreenDump(buf, 'Test_prop_inserts_text_visual_block_4', {})
|
||||
call term_sendkeys(buf, "Ol")
|
||||
call VerifyScreenDump(buf, 'Test_prop_inserts_text_visual_block_5', {})
|
||||
call term_sendkeys(buf, "l")
|
||||
call VerifyScreenDump(buf, 'Test_prop_inserts_text_visual_block_6', {})
|
||||
call term_sendkeys(buf, "l")
|
||||
call VerifyScreenDump(buf, 'Test_prop_inserts_text_visual_block_7', {})
|
||||
|
||||
call StopVimInTerminal(buf)
|
||||
endfunc
|
||||
|
||||
func Test_prop_add_with_text_fails()
|
||||
call prop_type_add('failing', #{highlight: 'ErrorMsg'})
|
||||
call assert_fails("call prop_add(1, 0, #{type: 'failing', text: 'X', end_lnum: 1})", 'E1305:')
|
||||
|
@ -695,6 +695,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1731,
|
||||
/**/
|
||||
1730,
|
||||
/**/
|
||||
|
Loading…
x
Reference in New Issue
Block a user