Mercurial > vim
diff src/testdir/test_autocmd.vim @ 13037:6e81a68d63a1 v8.0.1394
patch 8.0.1394: cannot intercept a yank command
commit https://github.com/vim/vim/commit/7e1652c63c96585b9e2235c195a3c322b1f11595
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Dec 16 18:27:02 2017 +0100
patch 8.0.1394: cannot intercept a yank command
Problem: Cannot intercept a yank command.
Solution: Add the TextYankPost autocommand event. (Philippe Vaucher et al.,
closes #2333)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 16 Dec 2017 18:30:05 +0100 |
parents | afd8a4f36301 |
children | 197a08152ad5 |
line wrap: on
line diff
--- a/src/testdir/test_autocmd.vim +++ b/src/testdir/test_autocmd.vim @@ -1124,3 +1124,42 @@ func Test_Filter_noshelltemp() let &shelltemp = shelltemp bwipe! endfunc + +func Test_TextYankPost() + enew! + call setline(1, ['foo']) + + let g:event = [] + au TextYankPost * let g:event = copy(v:event) + + call assert_equal({}, v:event) + call assert_fails('let v:event = {}', 'E46:') + call assert_fails('let v:event.mykey = 0', 'E742:') + + norm "ayiw + call assert_equal( + \{'regcontents': ['foo'], 'regname': 'a', 'operator': 'y', 'regtype': 'v'}, + \g:event) + norm y_ + call assert_equal( + \{'regcontents': ['foo'], 'regname': '', 'operator': 'y', 'regtype': 'V'}, + \g:event) + call feedkeys("\<C-V>y", 'x') + call assert_equal( + \{'regcontents': ['f'], 'regname': '', 'operator': 'y', 'regtype': "\x161"}, + \g:event) + norm "xciwbar + call assert_equal( + \{'regcontents': ['foo'], 'regname': 'x', 'operator': 'c', 'regtype': 'v'}, + \g:event) + norm "bdiw + call assert_equal( + \{'regcontents': ['bar'], 'regname': 'b', 'operator': 'd', 'regtype': 'v'}, + \g:event) + + call assert_equal({}, v:event) + + au! TextYankPost + unlet g:event + bwipe! +endfunc