Mercurial > vim
changeset 20754:e6a5a5ef4034 v8.2.0929
patch 8.2.0929: v:register is not cleared after an operator was executed
Commit: https://github.com/vim/vim/commit/cc613031b96f1cfa5a184253e745c26f1def9be4
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jun 7 21:31:18 2020 +0200
patch 8.2.0929: v:register is not cleared after an operator was executed
Problem: v:register is not cleared after an operator was executed.
Solution: Clear v:register after finishing an operator (Andy Massimino,
closes #5305)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 07 Jun 2020 21:45:04 +0200 |
parents | 661eb972cb22 |
children | c3f999111bfd |
files | src/normal.c src/testdir/test_registers.vim src/version.c |
diffstat | 3 files changed, 76 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/normal.c +++ b/src/normal.c @@ -1181,6 +1181,11 @@ normal_end: msg_nowait = FALSE; +#ifdef FEAT_EVAL + if (finish_op) + reset_reg_var(); +#endif + // Reset finish_op, in case it was set #ifdef CURSOR_SHAPE c = finish_op;
--- a/src/testdir/test_registers.vim +++ b/src/testdir/test_registers.vim @@ -488,4 +488,73 @@ func Test_set_register_dict() bwipe! endfunc +func Test_v_register() + enew + call setline(1, 'nothing') + + func s:Put() + let s:register = v:register + exec 'normal! "' .. v:register .. 'P' + endfunc + nnoremap <buffer> <plug>(test) :<c-u>call s:Put()<cr> + nmap <buffer> S <plug>(test) + + let @z = "testz\n" + let @" = "test@\n" + + let s:register = '' + call feedkeys('"_ddS', 'mx') + call assert_equal('test@', getline('.')) " fails before 8.2.0929 + call assert_equal('"', s:register) " fails before 8.2.0929 + + let s:register = '' + call feedkeys('"zS', 'mx') + call assert_equal('z', s:register) + + let s:register = '' + call feedkeys('"zSS', 'mx') + call assert_equal('"', s:register) + + let s:register = '' + call feedkeys('"_S', 'mx') + call assert_equal('_', s:register) + + let s:register = '' + normal "_ddS + call assert_equal('"', s:register) " fails before 8.2.0929 + call assert_equal('test@', getline('.')) " fails before 8.2.0929 + + let s:register = '' + execute 'normal "z:call' "s:Put()\n" + call assert_equal('z', s:register) + call assert_equal('testz', getline('.')) + + " Test operator and omap + let @b = 'testb' + func s:OpFunc(...) + let s:register2 = v:register + endfunc + set opfunc=s:OpFunc + + normal "bg@l + normal S + call assert_equal('"', s:register) " fails before 8.2.0929 + call assert_equal('b', s:register2) + + func s:Motion() + let s:register1 = v:register + normal! l + endfunc + onoremap <buffer> Q :<c-u>call s:Motion()<cr> + + normal "bg@Q + normal S + call assert_equal('"', s:register) + call assert_equal('b', s:register1) + call assert_equal('"', s:register2) + + set opfunc& + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab