mirror of
https://github.com/vim/vim.git
synced 2025-10-01 04:54:07 -04:00
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 #4192)
This commit is contained in:
@@ -4848,7 +4848,6 @@ f_getchar(typval_T *argvars, typval_T *rettv)
|
|||||||
{
|
{
|
||||||
varnumber_T n;
|
varnumber_T n;
|
||||||
int error = FALSE;
|
int error = FALSE;
|
||||||
int save_reg_executing = reg_executing;
|
|
||||||
|
|
||||||
#ifdef MESSAGE_QUEUE
|
#ifdef MESSAGE_QUEUE
|
||||||
// vpeekc() used to check for messages, but that caused problems, invoking
|
// vpeekc() used to check for messages, but that caused problems, invoking
|
||||||
@@ -4883,7 +4882,6 @@ f_getchar(typval_T *argvars, typval_T *rettv)
|
|||||||
}
|
}
|
||||||
--no_mapping;
|
--no_mapping;
|
||||||
--allow_keys;
|
--allow_keys;
|
||||||
reg_executing = save_reg_executing;
|
|
||||||
|
|
||||||
set_vim_var_nr(VV_MOUSE_WIN, 0);
|
set_vim_var_nr(VV_MOUSE_WIN, 0);
|
||||||
set_vim_var_nr(VV_MOUSE_WINID, 0);
|
set_vim_var_nr(VV_MOUSE_WINID, 0);
|
||||||
|
@@ -1699,6 +1699,7 @@ do_one_cmd(
|
|||||||
exarg_T ea; /* Ex command arguments */
|
exarg_T ea; /* Ex command arguments */
|
||||||
int save_msg_scroll = msg_scroll;
|
int save_msg_scroll = msg_scroll;
|
||||||
cmdmod_T save_cmdmod;
|
cmdmod_T save_cmdmod;
|
||||||
|
int save_reg_executing = reg_executing;
|
||||||
int ni; /* set when Not Implemented */
|
int ni; /* set when Not Implemented */
|
||||||
char_u *cmd;
|
char_u *cmd;
|
||||||
|
|
||||||
@@ -2579,6 +2580,7 @@ doend:
|
|||||||
|
|
||||||
free_cmdmod();
|
free_cmdmod();
|
||||||
cmdmod = save_cmdmod;
|
cmdmod = save_cmdmod;
|
||||||
|
reg_executing = save_reg_executing;
|
||||||
|
|
||||||
if (ea.save_msg_silent != -1)
|
if (ea.save_msg_silent != -1)
|
||||||
{
|
{
|
||||||
|
@@ -1150,20 +1150,38 @@ func Test_reg_executing_and_recording()
|
|||||||
" getchar() command saves and restores reg_executing
|
" getchar() command saves and restores reg_executing
|
||||||
map W :call TestFunc()<CR>
|
map W :call TestFunc()<CR>
|
||||||
let @q = "W"
|
let @q = "W"
|
||||||
|
let g:typed = ''
|
||||||
|
let g:regs = []
|
||||||
func TestFunc() abort
|
func TestFunc() abort
|
||||||
let g:reg1 = reg_executing()
|
let g:regs += [reg_executing()]
|
||||||
let g:typed = getchar(0)
|
let g:typed = getchar(0)
|
||||||
let g:reg2 = reg_executing()
|
let g:regs += [reg_executing()]
|
||||||
endfunc
|
endfunc
|
||||||
call feedkeys("@qy", 'xt')
|
call feedkeys("@qy", 'xt')
|
||||||
call assert_equal(char2nr("y"), g:typed)
|
call assert_equal(char2nr("y"), g:typed)
|
||||||
call assert_equal('q', g:reg1)
|
call assert_equal(['q', 'q'], g:regs)
|
||||||
call assert_equal('q', g:reg2)
|
|
||||||
delfunc TestFunc
|
delfunc TestFunc
|
||||||
unmap W
|
unmap W
|
||||||
unlet g:typed
|
unlet g:typed
|
||||||
unlet g:reg1
|
unlet g:regs
|
||||||
unlet g:reg2
|
|
||||||
|
" 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!
|
bwipe!
|
||||||
delfunc s:save_reg_stat
|
delfunc s:save_reg_stat
|
||||||
|
@@ -775,6 +775,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1077,
|
||||||
/**/
|
/**/
|
||||||
1076,
|
1076,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user