diff options
author | zeertzjq <zeertzjq@outlook.com> | 2021-10-19 22:39:25 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-19 07:39:25 -0700 |
commit | 308fd88d0d48a21460cdc61966b7f249f3d26981 (patch) | |
tree | 9a8b2451f7ceb701143c499d93ba3ef0ba95d0b8 /src | |
parent | bdd180b5d2be85999b10a86486d5b1bb127bb169 (diff) | |
download | rneovim-308fd88d0d48a21460cdc61966b7f249f3d26981.tar.gz rneovim-308fd88d0d48a21460cdc61966b7f249f3d26981.tar.bz2 rneovim-308fd88d0d48a21460cdc61966b7f249f3d26981.zip |
vim-patch:8.2.3537: wrong mode() during 'operatorfunc' #16087
Problem: mode() does not return the right value in 'operatorfunc'.
Solution: Reset finish_op while calling 'operatorfunc'.
https://github.com/vim/vim/commit/75c30e96cf280a8cc01ac01c41a9252db3e503cc
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/normal.c | 5 | ||||
-rw-r--r-- | src/nvim/testdir/test_functions.vim | 16 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 732e5ffc1f..686071e25a 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -2167,6 +2167,7 @@ static void op_function(const oparg_T *oap) FUNC_ATTR_NONNULL_ALL { const TriState save_virtual_op = virtual_op; + const bool save_finish_op = finish_op; if (*p_opfunc == NUL) { EMSG(_("E774: 'operatorfunc' is empty")); @@ -2193,9 +2194,13 @@ static void op_function(const oparg_T *oap) // function. virtual_op = kNone; + // Reset finish_op so that mode() returns the right value. + finish_op = false; + (void)call_func_retnr(p_opfunc, 1, argv); virtual_op = save_virtual_op; + finish_op = save_finish_op; } } diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index a0e9f780c6..d10fad690c 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -711,6 +711,20 @@ func Test_mode() call assert_equal('c-cv', g:current_modes) " How to test Ex mode? + " Test mode in operatorfunc (it used to be Operator-pending). + set operatorfunc=OperatorFunc + function OperatorFunc(_) + call Save_mode() + endfunction + execute "normal! g@l\<Esc>" + call assert_equal('n-n', g:current_modes) + execute "normal! i\<C-o>g@l\<Esc>" + call assert_equal('n-niI', g:current_modes) + execute "normal! R\<C-o>g@l\<Esc>" + call assert_equal('n-niR', g:current_modes) + execute "normal! gR\<C-o>g@l\<Esc>" + call assert_equal('n-niV', g:current_modes) + if has('terminal') term call feedkeys("\<C-W>N", 'xt') @@ -723,6 +737,8 @@ func Test_mode() iunmap <F2> xunmap <F2> set complete& + set operatorfunc& + delfunction OperatorFunc endfunc func Test_append() |