]> granicus.if.org Git - vim/commitdiff
patch 8.1.0995: a getchar() call resets the reg_executing() result v8.1.0995
authorBram Moolenaar <Bram@vim.org>
Tue, 5 Mar 2019 11:24:10 +0000 (12:24 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 5 Mar 2019 11:24:10 +0000 (12:24 +0100)
Problem:    A getchar() call while executing a register resets the
            reg_executing() result.
Solution:   Save and restore reg_executing. (closes #406

src/evalfunc.c
src/testdir/test_functions.vim
src/version.c

index 7cecab0658364b226b436b941a141e28ddfe6073..f59574d48f7900eaf0d3f2a80950be09e78ad382 100644 (file)
@@ -4811,6 +4811,7 @@ f_getchar(typval_T *argvars, typval_T *rettv)
 {
     varnumber_T                n;
     int                        error = FALSE;
+    int                        save_reg_executing = reg_executing;
 
 #ifdef MESSAGE_QUEUE
     // vpeekc() used to check for messages, but that caused problems, invoking
@@ -4845,6 +4846,7 @@ f_getchar(typval_T *argvars, typval_T *rettv)
     }
     --no_mapping;
     --allow_keys;
+    reg_executing = save_reg_executing;
 
     set_vim_var_nr(VV_MOUSE_WIN, 0);
     set_vim_var_nr(VV_MOUSE_WINID, 0);
index 43c0f63c21573e8c318194dc807ce7c755b12f9c..d53499950e8ef42e2824aca8142f90a950d8dab9 100644 (file)
@@ -1138,6 +1138,7 @@ func Test_reg_executing_and_recording()
   call assert_equal('":', s:reg_stat)
 
   " :normal command saves and restores reg_executing
+  let s:reg_stat = ''
   let @q = ":call TestFunc()\<CR>:call s:save_reg_stat()\<CR>"
   func TestFunc() abort
     normal! ia
@@ -1146,6 +1147,24 @@ func Test_reg_executing_and_recording()
   call assert_equal(':q', s:reg_stat)
   delfunc TestFunc
 
+  " 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
index 6279847e89c7cdc68a13523666abbf6b3f08a4f9..70a43d52c971385a635a669d061d956df296aa61 100644 (file)
@@ -779,6 +779,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    995,
 /**/
     994,
 /**/