diff options
author | Christian Clason <christian.clason@uni-due.de> | 2020-06-03 16:51:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-03 10:51:25 -0400 |
commit | 8a1276005a1099187710bdcc19284de51a0aa89a (patch) | |
tree | bda3d6bb3a448c171539d8367d281816664212ae /src | |
parent | 60c581b35db439dd6b32cdc2ebe1a5aed933b44c (diff) | |
download | rneovim-8a1276005a1099187710bdcc19284de51a0aa89a.tar.gz rneovim-8a1276005a1099187710bdcc19284de51a0aa89a.tar.bz2 rneovim-8a1276005a1099187710bdcc19284de51a0aa89a.zip |
Add v:event.visual during `TextYankPost` (#12382)
* propagate visual selection to textyankpost event
* adapt tests
* add docs
* also adapt oldtest
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/ops.c | 4 | ||||
-rw-r--r-- | src/nvim/testdir/test_autocmd.vim | 10 |
2 files changed, 9 insertions, 5 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c index a70224f98b..755c1519fd 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -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); diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 954e5d875f..5217aa7339 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -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) |