diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2019-05-26 20:50:54 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2019-05-26 20:55:44 -0400 |
commit | 23936115880ba3c9e716f9c3b5d7b89453cd65fc (patch) | |
tree | 2800583f742ac06c4ba7bb5b0c754a04cdd9cb0e | |
parent | 21f160746a4b406f84311a64fff96c1bd52f23c9 (diff) | |
download | rneovim-23936115880ba3c9e716f9c3b5d7b89453cd65fc.tar.gz rneovim-23936115880ba3c9e716f9c3b5d7b89453cd65fc.tar.bz2 rneovim-23936115880ba3c9e716f9c3b5d7b89453cd65fc.zip |
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
-rw-r--r-- | src/nvim/eval.c | 2 | ||||
-rw-r--r-- | src/nvim/testdir/test_functions.vim | 21 |
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 |