Skip to content

Commit f0fab30

Browse files
committed
patch 8.1.0995: a getchar() call resets the reg_executing() result
Problem: A getchar() call while executing a register resets the reg_executing() result. Solution: Save and restore reg_executing. (closes #406
1 parent 8fcb60f commit f0fab30

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

src/evalfunc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4811,6 +4811,7 @@ f_getchar(typval_T *argvars, typval_T *rettv)
48114811
{
48124812
varnumber_T n;
48134813
int error = FALSE;
4814+
int save_reg_executing = reg_executing;
48144815

48154816
#ifdef MESSAGE_QUEUE
48164817
// vpeekc() used to check for messages, but that caused problems, invoking
@@ -4845,6 +4846,7 @@ f_getchar(typval_T *argvars, typval_T *rettv)
48454846
}
48464847
--no_mapping;
48474848
--allow_keys;
4849+
reg_executing = save_reg_executing;
48484850

48494851
set_vim_var_nr(VV_MOUSE_WIN, 0);
48504852
set_vim_var_nr(VV_MOUSE_WINID, 0);

src/testdir/test_functions.vim

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,6 +1138,7 @@ func Test_reg_executing_and_recording()
11381138
call assert_equal('":', s:reg_stat)
11391139

11401140
" :normal command saves and restores reg_executing
1141+
let s:reg_stat = ''
11411142
let @q = ":call TestFunc()\<CR>:call s:save_reg_stat()\<CR>"
11421143
func TestFunc() abort
11431144
normal! ia
@@ -1146,6 +1147,24 @@ func Test_reg_executing_and_recording()
11461147
call assert_equal(':q', s:reg_stat)
11471148
delfunc TestFunc
11481149

1150+
" getchar() command saves and restores reg_executing
1151+
map W :call TestFunc()<CR>
1152+
let @q = "W"
1153+
func TestFunc() abort
1154+
let g:reg1 = reg_executing()
1155+
let g:typed = getchar(0)
1156+
let g:reg2 = reg_executing()
1157+
endfunc
1158+
call feedkeys("@qy", 'xt')
1159+
call assert_equal(char2nr("y"), g:typed)
1160+
call assert_equal('q', g:reg1)
1161+
call assert_equal('q', g:reg2)
1162+
delfunc TestFunc
1163+
unmap W
1164+
unlet g:typed
1165+
unlet g:reg1
1166+
unlet g:reg2
1167+
11491168
bwipe!
11501169
delfunc s:save_reg_stat
11511170
unlet s:reg_stat

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,8 @@ static char *(features[]) =
779779

780780
static int included_patches[] =
781781
{ /* Add new patch number below this line */
782+
/**/
783+
995,
782784
/**/
783785
994,
784786
/**/

0 commit comments

Comments
 (0)