aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval.c2
-rw-r--r--src/nvim/testdir/test_functions.vim21
2 files changed, 23 insertions, 0 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index aa4a3da9e5..6eb4263a0c 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -9673,6 +9673,7 @@ 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 (;; ) {
@@ -9709,6 +9710,7 @@ 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;
diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim
index e41af6d7f2..d58e4f8758 100644
--- a/src/nvim/testdir/test_functions.vim
+++ b/src/nvim/testdir/test_functions.vim
@@ -1097,6 +1097,27 @@ func Test_reg_executing_and_recording()
call feedkeys("q\"\"=s:save_reg_stat()\<CR>pq", 'xt')
call assert_equal('":', s:reg_stat)
+ " :normal command saves and restores reg_executing
+ let s:reg_stat = ''
+
+ " getchar() command saves and restores reg_executing
+ map W :call TestFunc()<CR>
+ let @q = "W"
+ func TestFunc() abort
+ let g:reg1 = reg_executing()
+ let g:typed = getchar(0)
+ let g:reg2 = 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)
+ delfunc TestFunc
+ unmap W
+ unlet g:typed
+ unlet g:reg1
+ unlet g:reg2
+
bwipe!
delfunc s:save_reg_stat
unlet s:reg_stat