From 23936115880ba3c9e716f9c3b5d7b89453cd65fc Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 26 May 2019 20:50:54 -0400 Subject: vim-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 vim/vim#406 https://github.com/vim/vim/commit/f0fab3046c2b5c4115979347464a802853011220 --- src/nvim/eval.c | 2 ++ src/nvim/testdir/test_functions.vim | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) 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()\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() + 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 -- cgit