mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.1.1077: reg_executing() is reset by calling input()
Problem: reg_executing() is reset by calling input().
Solution: Implement a more generic way to save and restore reg_executing.
(Ozaki Kiichi, closes vim/vim#4192)
9a2c091a74
This commit is contained in:
parent
2393611588
commit
b2a11515b2
@ -9673,7 +9673,6 @@ static void f_getchar(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
{
|
||||
varnumber_T n;
|
||||
bool error = false;
|
||||
const int save_reg_executing = reg_executing;
|
||||
|
||||
no_mapping++;
|
||||
for (;; ) {
|
||||
@ -9710,7 +9709,6 @@ static void f_getchar(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
break;
|
||||
}
|
||||
no_mapping--;
|
||||
reg_executing = save_reg_executing;
|
||||
|
||||
vimvars[VV_MOUSE_WIN].vv_nr = 0;
|
||||
vimvars[VV_MOUSE_WINID].vv_nr = 0;
|
||||
|
@ -1233,6 +1233,7 @@ static char_u * do_one_cmd(char_u **cmdlinep,
|
||||
int did_esilent = 0;
|
||||
int did_sandbox = FALSE;
|
||||
cmdmod_T save_cmdmod;
|
||||
const int save_reg_executing = reg_executing;
|
||||
int ni; /* set when Not Implemented */
|
||||
char_u *cmd;
|
||||
int address_count = 1;
|
||||
@ -2298,6 +2299,7 @@ doend:
|
||||
}
|
||||
|
||||
cmdmod = save_cmdmod;
|
||||
reg_executing = save_reg_executing;
|
||||
|
||||
if (save_msg_silent != -1) {
|
||||
/* messages could be enabled for a serious error, need to check if the
|
||||
|
@ -1103,20 +1103,38 @@ func Test_reg_executing_and_recording()
|
||||
" getchar() command saves and restores reg_executing
|
||||
map W :call TestFunc()<CR>
|
||||
let @q = "W"
|
||||
let g:typed = ''
|
||||
let g:regs = []
|
||||
func TestFunc() abort
|
||||
let g:reg1 = reg_executing()
|
||||
let g:regs += [reg_executing()]
|
||||
let g:typed = getchar(0)
|
||||
let g:reg2 = reg_executing()
|
||||
let g:regs += [reg_executing()]
|
||||
endfunc
|
||||
call feedkeys("@qy", 'xt')
|
||||
call assert_equal(char2nr("y"), g:typed)
|
||||
call assert_equal('q', g:reg1)
|
||||
call assert_equal('q', g:reg2)
|
||||
call assert_equal(['q', 'q'], g:regs)
|
||||
delfunc TestFunc
|
||||
unmap W
|
||||
unlet g:typed
|
||||
unlet g:reg1
|
||||
unlet g:reg2
|
||||
unlet g:regs
|
||||
|
||||
" input() command saves and restores reg_executing
|
||||
map W :call TestFunc()<CR>
|
||||
let @q = "W"
|
||||
let g:typed = ''
|
||||
let g:regs = []
|
||||
func TestFunc() abort
|
||||
let g:regs += [reg_executing()]
|
||||
let g:typed = input('?')
|
||||
let g:regs += [reg_executing()]
|
||||
endfunc
|
||||
call feedkeys("@qy\<CR>", 'xt')
|
||||
call assert_equal("y", g:typed)
|
||||
call assert_equal(['q', 'q'], g:regs)
|
||||
delfunc TestFunc
|
||||
unmap W
|
||||
unlet g:typed
|
||||
unlet g:regs
|
||||
|
||||
bwipe!
|
||||
delfunc s:save_reg_stat
|
||||
|
Loading…
Reference in New Issue
Block a user