To: vim_dev@googlegroups.com Subject: Patch 8.2.3644 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3644 Problem: Count for 'operatorfunc' in Visual mode is not redone. Solution: Add the count to the redo buffer. (closes #9174) Files: src/normal.c, src/proto/normal.pro, src/ops.c, src/testdir/test_normal.vim *** ../vim-8.2.3643/src/normal.c 2021-11-17 18:00:28.189010856 +0000 --- src/normal.c 2021-11-22 14:03:34.522543337 +0000 *************** *** 380,387 **** --- 380,389 ---- // Number of commands in nv_cmds[]. #define NV_CMDS_SIZE ARRAY_LENGTH(nv_cmds) + #ifndef PROTO // cproto doesn't like this // Sorted index of commands in nv_cmds[]. static short nv_cmd_idx[NV_CMDS_SIZE]; + #endif // The highest index for which // nv_cmds[idx].cmd_char == nv_cmd_idx[nv_cmds[idx].cmd_char] *************** *** 1697,1715 **** int cmd4, int cmd5) { ResetRedobuff(); if (regname != 0) // yank from specified buffer { AppendCharToRedobuff('"'); AppendCharToRedobuff(regname); } ! if (num) ! AppendNumberToRedobuff(num); ! if (cmd1 != NUL) AppendCharToRedobuff(cmd1); if (cmd2 != NUL) AppendCharToRedobuff(cmd2); if (cmd3 != NUL) AppendCharToRedobuff(cmd3); if (cmd4 != NUL) --- 1699,1735 ---- int cmd4, int cmd5) { + prep_redo_num2(regname, num, cmd1, cmd2, 0L, cmd3, cmd4, cmd5); + } + + /* + * Prepare for redo of any command with extra count after "cmd2". + */ + void + prep_redo_num2( + int regname, + long num1, + int cmd1, + int cmd2, + long num2, + int cmd3, + int cmd4, + int cmd5) + { ResetRedobuff(); if (regname != 0) // yank from specified buffer { AppendCharToRedobuff('"'); AppendCharToRedobuff(regname); } ! if (num1 != 0) ! AppendNumberToRedobuff(num1); if (cmd1 != NUL) AppendCharToRedobuff(cmd1); if (cmd2 != NUL) AppendCharToRedobuff(cmd2); + if (num2 != 0) + AppendNumberToRedobuff(num2); if (cmd3 != NUL) AppendCharToRedobuff(cmd3); if (cmd4 != NUL) *** ../vim-8.2.3643/src/proto/normal.pro 2021-06-03 21:11:04.418516318 +0100 --- src/proto/normal.pro 2021-11-22 14:03:16.714574095 +0000 *************** *** 10,15 **** --- 10,16 ---- int find_ident_under_cursor(char_u **text, int find_type); int find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, char_u **text, int *textcol, int find_type); void prep_redo(int regname, long num, int cmd1, int cmd2, int cmd3, int cmd4, int cmd5); + void prep_redo_num2(int regname, long num1, int cmd1, int cmd2, long num2, int cmd3, int cmd4, int cmd5); void clearop(oparg_T *oap); void clearopbeep(oparg_T *oap); void may_clear_cmdline(void); *** ../vim-8.2.3643/src/ops.c 2021-11-18 22:08:52.007682711 +0000 --- src/ops.c 2021-11-22 14:02:05.530700742 +0000 *************** *** 3764,3769 **** --- 3764,3771 ---- oap->motion_force, cap->cmdchar, cap->nchar); else if (cap->cmdchar != ':' && cap->cmdchar != K_COMMAND) { + int opchar = get_op_char(oap->op_type); + int extra_opchar = get_extra_op_char(oap->op_type); int nchar = oap->op_type == OP_REPLACE ? cap->nchar : NUL; // reverse what nv_replace() did *************** *** 3771,3780 **** nchar = CAR; else if (nchar == REPLACE_NL_NCHAR) nchar = NL; ! prep_redo(oap->regname, 0L, NUL, 'v', ! get_op_char(oap->op_type), ! get_extra_op_char(oap->op_type), ! nchar); } if (!redo_VIsual_busy) { --- 3773,3786 ---- nchar = CAR; else if (nchar == REPLACE_NL_NCHAR) nchar = NL; ! ! if (opchar == 'g' && extra_opchar == '@') ! // also repeat the count for 'operatorfunc' ! prep_redo_num2(oap->regname, 0L, NUL, 'v', ! cap->count0, opchar, extra_opchar, nchar); ! else ! prep_redo(oap->regname, 0L, NUL, 'v', ! opchar, extra_opchar, nchar); } if (!redo_VIsual_busy) { *** ../vim-8.2.3643/src/testdir/test_normal.vim 2021-11-21 11:35:59.456938797 +0000 --- src/testdir/test_normal.vim 2021-11-22 14:08:23.010084036 +0000 *************** *** 363,369 **** bw! endfunc ! func Test_normal09_operatorfunc() " Test operatorfunc call Setup_NewWindow() " Add some spaces for counting --- 363,369 ---- bw! endfunc ! func Test_normal09a_operatorfunc() " Test operatorfunc call Setup_NewWindow() " Add some spaces for counting *************** *** 457,463 **** bw! endfunc ! func Test_normal09a_operatorfunc() " Test operatorfunc call Setup_NewWindow() " Add some spaces for counting --- 457,463 ---- bw! endfunc ! func Test_normal09b_operatorfunc() " Test operatorfunc call Setup_NewWindow() " Add some spaces for counting *************** *** 484,489 **** --- 484,509 ---- unlet! g:opt endfunc + func OperatorfuncRedo(_) + let g:opfunc_count = v:count + endfunc + + func Test_normal09c_operatorfunc() + " Test redoing operatorfunc + new + call setline(1, 'some text') + set operatorfunc=OperatorfuncRedo + normal v3g@ + call assert_equal(3, g:opfunc_count) + let g:opfunc_count = 0 + normal . + call assert_equal(3, g:opfunc_count) + + bw! + unlet g:opfunc_count + set operatorfunc= + endfunc + func Test_normal10_expand() " Test for expand() 10new *** ../vim-8.2.3643/src/version.c 2021-11-22 12:47:36.323593289 +0000 --- src/version.c 2021-11-22 13:56:30.199399227 +0000 *************** *** 759,760 **** --- 759,762 ---- { /* Add new patch number below this line */ + /**/ + 3644, /**/ -- [Another hideous roar.] BEDEVERE: That's it! ARTHUR: What? BEDEVERE: It's The Legendary Black Beast of Aaaaarrrrrrggghhh! "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// 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 ///