Problem: Visual selection may be drawn incorrectly with "autoselect".
Solution: Restore w_virtcol after getting clipboard selection
(zeertzjq).
fixes: #19590
closes: #19784
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
pos_T old_cursor;
pos_T old_visual;
int old_visual_mode;
+ colnr_T old_virtcol;
colnr_T old_curswant;
int old_set_curswant;
pos_T old_op_start, old_op_end;
old_y_previous = get_y_previous();
old_y_current = get_y_current();
old_cursor = curwin->w_cursor;
+ old_virtcol = curwin->w_virtcol;
old_curswant = curwin->w_curswant;
old_set_curswant = curwin->w_set_curswant;
old_op_start = curbuf->b_op_start;
set_y_previous(old_y_previous);
set_y_current(old_y_current);
curwin->w_cursor = old_cursor;
- changed_cline_bef_curs(); // need to update w_virtcol et al
+ curwin->w_virtcol = old_virtcol;
+ changed_cline_bef_curs(); // old w_virtcol et al. may be invalid
curwin->w_curswant = old_curswant;
curwin->w_set_curswant = old_set_curswant;
curbuf->b_op_start = old_op_start;
--- /dev/null
+|a+0&#ffffff0@4| |a@9|(|a@8| |a@3|)| @42
+|{| @73
+@8|a+0#0000001#a8a8a8255|a+0#0000000#ffffff0@21|;| @42
+@8|a+0#0000001#a8a8a8255|a+0#0000000#ffffff0@21|;| @42
+@8|a+0#0000001#a8a8a8255|a+0#0000000#ffffff0@21|;| @42
+@8|a+0#0000001#a8a8a8255|a+0#0000000#ffffff0@21|;| @42
+@8>a@22|;| @42
+|}| @73
+|~+0#4040ff13&| @73
+|-+2#0000000&@1| |V|I|S|U|A|L| |B|L|O|C|K| |-@1| +0&&@28|5|x|1| @6|7|,|2|-|9| @8|A|l@1|
--- /dev/null
+|a+0&#ffffff0@4| |a@9|(|a@8| |a@3|)| @42
+|{| @73
+@8|a+0#0000001#a8a8a8255@1|a+0#0000000#ffffff0@20|;| @42
+@8|a+0#0000001#a8a8a8255@1|a+0#0000000#ffffff0@20|;| @42
+@8|a+0#0000001#a8a8a8255@1|a+0#0000000#ffffff0@20|;| @42
+@8|a+0#0000001#a8a8a8255@1|a+0#0000000#ffffff0@20|;| @42
+@8|a+0#0000001#a8a8a8255>a+0#0000000#ffffff0@21|;| @42
+|}| @73
+|~+0#4040ff13&| @73
+|-+2#0000000&@1| |V|I|S|U|A|L| |B|L|O|C|K| |-@1| +0&&@28|5|x|2| @6|7|,|3|-|1|0| @7|A|l@1|
--- /dev/null
+|a+0&#ffffff0@4| |a@9|(|a@8| |a@3|)| @42
+|{| @73
+@8|a+0#0000001#a8a8a8255@2|a+0#0000000#ffffff0@19|;| @42
+@8|a+0#0000001#a8a8a8255@2|a+0#0000000#ffffff0@19|;| @42
+@8|a+0#0000001#a8a8a8255@2|a+0#0000000#ffffff0@19|;| @42
+@8|a+0#0000001#a8a8a8255@2|a+0#0000000#ffffff0@19|;| @42
+@8|a+0#0000001#a8a8a8255@1>a+0#0000000#ffffff0@20|;| @42
+|}| @73
+|~+0#4040ff13&| @73
+|-+2#0000000&@1| |V|I|S|U|A|L| |B|L|O|C|K| |-@1| +0&&@28|5|x|3| @6|7|,|4|-|1@1| @7|A|l@1|
--- /dev/null
+|a+0&#ffffff0@4| |a@9|(|a@8| |a@3|)| @42
+|{| @73
+@8|a+0#0000001#a8a8a8255@3|a+0#0000000#ffffff0@18|;| @42
+@8|a+0#0000001#a8a8a8255@3|a+0#0000000#ffffff0@18|;| @42
+@8|a+0#0000001#a8a8a8255@3|a+0#0000000#ffffff0@18|;| @42
+@8|a+0#0000001#a8a8a8255@3|a+0#0000000#ffffff0@18|;| @42
+@8|a+0#0000001#a8a8a8255@2>a+0#0000000#ffffff0@19|;| @42
+|}| @73
+|~+0#4040ff13&| @73
+|-+2#0000000&@1| |V|I|S|U|A|L| |B|L|O|C|K| |-@1| +0&&@28|5|x|4| @6|7|,|5|-|1|2| @7|A|l@1|
--- /dev/null
+|a+0&#ffffff0@4| |a@9|(|a@8| |a@3|)| @42
+|{| @73
+@8|a+0#0000001#a8a8a8255@4|a+0#0000000#ffffff0@17|;| @42
+@8|a+0#0000001#a8a8a8255@4|a+0#0000000#ffffff0@17|;| @42
+@8|a+0#0000001#a8a8a8255@4|a+0#0000000#ffffff0@17|;| @42
+@8|a+0#0000001#a8a8a8255@4|a+0#0000000#ffffff0@17|;| @42
+@8|a+0#0000001#a8a8a8255@3>a+0#0000000#ffffff0@18|;| @42
+|}| @73
+|~+0#4040ff13&| @73
+|-+2#0000000&@1| |V|I|S|U|A|L| |B|L|O|C|K| |-@1| +0&&@28|5|x|5| @6|7|,|6|-|1|3| @7|A|l@1|
--- /dev/null
+aaaaa aaaaaaaaaa(aaaaaaaaa aaaa)
+{
+ aaaaaaaaaaaaaaaaaaaaaaa;
+ aaaaaaaaaaaaaaaaaaaaaaa;
+ aaaaaaaaaaaaaaaaaaaaaaa;
+ aaaaaaaaaaaaaaaaaaaaaaa;
+ aaaaaaaaaaaaaaaaaaaaaaa;
+}
call StopVimInTerminal(buf)
endfunc
+" Test for https://github.com/vim/vim/issues/19590
+func Test_visual_block_hl_with_autoselect()
+ CheckScreendump
+
+ " "autoselect" is included in the default 'clipboard' if available.
+ " Redraw at the end is necessary due to https://github.com/vim/vim/issues/16620
+ let lines =<< trim END
+ set shortmess+=F
+ edit samples/visual_block_hl.txt
+ setlocal filetype=c syntax=c
+ exe "normal! 3gg0l\<C-V>4j"
+ redraw
+ END
+ call writefile(lines, 'XTest_visual_block_autoselect', 'D')
+
+ let buf = RunVimInTerminal('-S XTest_visual_block_autoselect', {'rows': 10})
+ call VerifyScreenDump(buf, 'Test_visual_block_hl_with_autoselect_1', {})
+ call term_sendkeys(buf, 'l')
+ call VerifyScreenDump(buf, 'Test_visual_block_hl_with_autoselect_2', {})
+ call term_sendkeys(buf, 'l')
+ call VerifyScreenDump(buf, 'Test_visual_block_hl_with_autoselect_3', {})
+ call term_sendkeys(buf, 'l')
+ call VerifyScreenDump(buf, 'Test_visual_block_hl_with_autoselect_4', {})
+ call term_sendkeys(buf, 'l')
+ call VerifyScreenDump(buf, 'Test_visual_block_hl_with_autoselect_5', {})
+
+ " clean up
+ call term_sendkeys(buf, "\<Esc>")
+ call StopVimInTerminal(buf)
+endfunc
+
func Test_visual_highlight_when_using_a_clipboard_provider()
" The test assumes different screen attributes will be used for Visual and for VisualNOS.
CheckFeature clipboard_provider
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 221,
/**/
220,
/**/