To: vim_dev@googlegroups.com Subject: Patch 8.2.3537 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3537 Problem: mode() does not return the right value in 'operatorfunc'. Solution: Reset finish_op while calling 'operatorfunc'. Files: src/ops.c, src/testdir/test_functions.vim *** ../vim-8.2.3536/src/ops.c 2021-09-14 17:55:47.864129826 +0100 --- src/ops.c 2021-10-19 11:14:29.109680066 +0100 *************** *** 3314,3319 **** --- 3314,3320 ---- #ifdef FEAT_EVAL typval_T argv[2]; int save_virtual_op = virtual_op; + int save_finish_op = finish_op; pos_T orig_start = curbuf->b_op_start; pos_T orig_end = curbuf->b_op_end; *************** *** 3341,3349 **** --- 3342,3354 ---- // function. virtual_op = MAYBE; + // Reset finish_op so that mode() returns the right value. + finish_op = FALSE; + (void)call_func_noret(p_opfunc, 1, argv); virtual_op = save_virtual_op; + finish_op = save_finish_op; if (cmdmod.cmod_flags & CMOD_LOCKMARKS) { curbuf->b_op_start = orig_start; *** ../vim-8.2.3536/src/testdir/test_functions.vim 2021-10-16 13:00:10.940165406 +0100 --- src/testdir/test_functions.vim 2021-10-19 11:13:05.908465385 +0100 *************** *** 912,917 **** --- 912,931 ---- call assert_equal('c-ce', 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\" + call assert_equal('n-n', g:current_modes) + execute "normal! i\g@l\" + call assert_equal('n-niI', g:current_modes) + execute "normal! R\g@l\" + call assert_equal('n-niR', g:current_modes) + execute "normal! gR\g@l\" + call assert_equal('n-niV', g:current_modes) + if has('terminal') term call feedkeys("\N", 'xt') *************** *** 924,929 **** --- 938,945 ---- iunmap xunmap set complete& + set operatorfunc& + delfunction OperatorFunc endfunc " Test for append() *** ../vim-8.2.3536/src/version.c 2021-10-18 22:13:53.468428157 +0100 --- src/version.c 2021-10-19 11:14:58.870113933 +0100 *************** *** 759,760 **** --- 759,762 ---- { /* Add new patch number below this line */ + /**/ + 3537, /**/ -- % cat /usr/include/sys/errno.h #define EPERM 1 /* Operation not permitted */ #define ENOENT 2 /* No such file or directory */ #define ESRCH 3 /* No such process */ [...] #define EMACS 666 /* Too many macros */ % /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///