mirror of
https://github.com/neovim/neovim.git
synced 2025-10-06 01:46:29 +00:00
Add v:event.visual during TextYankPost
(#12382)
* propagate visual selection to textyankpost event * adapt tests * add docs * also adapt oldtest
This commit is contained in:
@@ -2748,6 +2748,10 @@ static void do_autocmd_textyankpost(oparg_T *oap, yankreg_T *reg)
|
||||
buf[1] = NUL;
|
||||
tv_dict_add_str(dict, S_LEN("operator"), buf);
|
||||
|
||||
// Selection type: visual or not.
|
||||
tv_dict_add_special(dict, S_LEN("visual"),
|
||||
oap->is_VIsual ? kSpecialVarTrue : kSpecialVarFalse);
|
||||
|
||||
tv_dict_set_keys_readonly(dict);
|
||||
textlock++;
|
||||
apply_autocmds(EVENT_TEXTYANKPOST, NULL, NULL, false, curbuf);
|
||||
|
@@ -1246,23 +1246,23 @@ func Test_TextYankPost()
|
||||
|
||||
norm "ayiw
|
||||
call assert_equal(
|
||||
\{'regcontents': ['foo'], 'inclusive': v:true, 'regname': 'a', 'operator': 'y', 'regtype': 'v'},
|
||||
\{'regcontents': ['foo'], 'inclusive': v:true, 'regname': 'a', 'operator': 'y', 'visual': v:false, 'regtype': 'v'},
|
||||
\g:event)
|
||||
norm y_
|
||||
call assert_equal(
|
||||
\{'regcontents': ['foo'], 'inclusive': v:false, 'regname': '', 'operator': 'y', 'regtype': 'V'},
|
||||
\{'regcontents': ['foo'], 'inclusive': v:false, 'regname': '', 'operator': 'y', 'visual': v:false, 'regtype': 'V'},
|
||||
\g:event)
|
||||
call feedkeys("\<C-V>y", 'x')
|
||||
call assert_equal(
|
||||
\{'regcontents': ['f'], 'inclusive': v:true, 'regname': '', 'operator': 'y', 'regtype': "\x161"},
|
||||
\{'regcontents': ['f'], 'inclusive': v:true, 'regname': '', 'operator': 'y', 'visual': v:true, 'regtype': "\x161"},
|
||||
\g:event)
|
||||
norm "xciwbar
|
||||
call assert_equal(
|
||||
\{'regcontents': ['foo'], 'inclusive': v:true, 'regname': 'x', 'operator': 'c', 'regtype': 'v'},
|
||||
\{'regcontents': ['foo'], 'inclusive': v:true, 'regname': 'x', 'operator': 'c', 'visual': v:false, 'regtype': 'v'},
|
||||
\g:event)
|
||||
norm "bdiw
|
||||
call assert_equal(
|
||||
\{'regcontents': ['bar'], 'inclusive': v:true, 'regname': 'b', 'operator': 'd', 'regtype': 'v'},
|
||||
\{'regcontents': ['bar'], 'inclusive': v:true, 'regname': 'b', 'operator': 'd', 'visual': v:false, 'regtype': 'v'},
|
||||
\g:event)
|
||||
|
||||
call assert_equal({}, v:event)
|
||||
|
Reference in New Issue
Block a user