mirror of
https://github.com/neovim/neovim.git
synced 2025-09-08 12:28:18 +00:00
vim-patch:8.2.3644: count for 'operatorfunc' in Visual mode is not redone
Problem: Count for 'operatorfunc' in Visual mode is not redone.
Solution: Add the count to the redo buffer. (closes vim/vim#9174)
2228cd72cf
Cherry-pick a line from patch 8.2.0522.
This commit is contained in:
@@ -2493,22 +2493,31 @@ static void prep_redo_cmd(cmdarg_T *cap)
|
|||||||
/// Prepare for redo of any command.
|
/// Prepare for redo of any command.
|
||||||
/// Note that only the last argument can be a multi-byte char.
|
/// Note that only the last argument can be a multi-byte char.
|
||||||
void prep_redo(int regname, long num, int cmd1, int cmd2, int cmd3, int cmd4, int cmd5)
|
void prep_redo(int regname, long num, int cmd1, int cmd2, int cmd3, 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();
|
ResetRedobuff();
|
||||||
if (regname != 0) { // yank from specified buffer
|
if (regname != 0) { // yank from specified buffer
|
||||||
AppendCharToRedobuff('"');
|
AppendCharToRedobuff('"');
|
||||||
AppendCharToRedobuff(regname);
|
AppendCharToRedobuff(regname);
|
||||||
}
|
}
|
||||||
if (num) {
|
if (num1 != 0) {
|
||||||
AppendNumberToRedobuff(num);
|
AppendNumberToRedobuff(num1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd1 != NUL) {
|
if (cmd1 != NUL) {
|
||||||
AppendCharToRedobuff(cmd1);
|
AppendCharToRedobuff(cmd1);
|
||||||
}
|
}
|
||||||
if (cmd2 != NUL) {
|
if (cmd2 != NUL) {
|
||||||
AppendCharToRedobuff(cmd2);
|
AppendCharToRedobuff(cmd2);
|
||||||
}
|
}
|
||||||
|
if (num2 != 0) {
|
||||||
|
AppendNumberToRedobuff(num2);
|
||||||
|
}
|
||||||
if (cmd3 != NUL) {
|
if (cmd3 != NUL) {
|
||||||
AppendCharToRedobuff(cmd3);
|
AppendCharToRedobuff(cmd3);
|
||||||
}
|
}
|
||||||
|
@@ -6485,6 +6485,8 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
|
|||||||
get_op_char(oap->op_type), get_extra_op_char(oap->op_type),
|
get_op_char(oap->op_type), get_extra_op_char(oap->op_type),
|
||||||
oap->motion_force, cap->cmdchar, cap->nchar);
|
oap->motion_force, cap->cmdchar, cap->nchar);
|
||||||
} else if (cap->cmdchar != ':' && cap->cmdchar != K_COMMAND) {
|
} 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;
|
int nchar = oap->op_type == OP_REPLACE ? cap->nchar : NUL;
|
||||||
|
|
||||||
// reverse what nv_replace() did
|
// reverse what nv_replace() did
|
||||||
@@ -6493,8 +6495,13 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
|
|||||||
} else if (nchar == REPLACE_NL_NCHAR) {
|
} else if (nchar == REPLACE_NL_NCHAR) {
|
||||||
nchar = NL;
|
nchar = NL;
|
||||||
}
|
}
|
||||||
prep_redo(oap->regname, 0L, NUL, 'v', get_op_char(oap->op_type),
|
|
||||||
get_extra_op_char(oap->op_type), nchar);
|
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) {
|
if (!redo_VIsual_busy) {
|
||||||
redo_VIsual_mode = resel_VIsual_mode;
|
redo_VIsual_mode = resel_VIsual_mode;
|
||||||
|
@@ -345,7 +345,7 @@ func Test_normal08_fold()
|
|||||||
bw!
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_normal09_operatorfunc()
|
func Test_normal09a_operatorfunc()
|
||||||
" Test operatorfunc
|
" Test operatorfunc
|
||||||
call Setup_NewWindow()
|
call Setup_NewWindow()
|
||||||
" Add some spaces for counting
|
" Add some spaces for counting
|
||||||
@@ -375,7 +375,7 @@ func Test_normal09_operatorfunc()
|
|||||||
bw!
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_normal09a_operatorfunc()
|
func Test_normal09b_operatorfunc()
|
||||||
" Test operatorfunc
|
" Test operatorfunc
|
||||||
call Setup_NewWindow()
|
call Setup_NewWindow()
|
||||||
" Add some spaces for counting
|
" Add some spaces for counting
|
||||||
@@ -397,10 +397,31 @@ func Test_normal09a_operatorfunc()
|
|||||||
" clean up
|
" clean up
|
||||||
unmap <buffer> ,,
|
unmap <buffer> ,,
|
||||||
set opfunc=
|
set opfunc=
|
||||||
|
call assert_fails('normal Vg@', 'E774:')
|
||||||
bw!
|
bw!
|
||||||
unlet! g:opt
|
unlet! g:opt
|
||||||
endfunc
|
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()
|
func Test_normal10_expand()
|
||||||
" Test for expand()
|
" Test for expand()
|
||||||
10new
|
10new
|
||||||
|
Reference in New Issue
Block a user