From 21f160746a4b406f84311a64fff96c1bd52f23c9 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 26 May 2019 19:39:38 -0400 Subject: vim-patch:8.1.0020: cannot tell whether a register is executing or recording Problem: Cannot tell whether a register is being used for executing or recording. Solution: Add reg_executing() and reg_recording(). (Hirohito Higashi, closes vim/vim#2745) Rename the global variables for consistency. Store the register name in reg_executing. https://github.com/vim/vim/commit/0b6d911e5de1a1c10a23d4c2ee1b0275c474a2dd --- src/nvim/testdir/test_functions.vim | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/nvim/testdir/test_functions.vim') diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index 46c2d0f4cd..e41af6d7f2 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -1076,3 +1076,28 @@ func Test_func_sandbox() call assert_fails('call Fsandbox()', 'E48:') delfunc Fsandbox endfunc + +" Test for reg_recording() and reg_executing() +func Test_reg_executing_and_recording() + let s:reg_stat = '' + func s:save_reg_stat() + let s:reg_stat = reg_recording() . ':' . reg_executing() + return '' + endfunc + + new + call s:save_reg_stat() + call assert_equal(':', s:reg_stat) + call feedkeys("qa\"=s:save_reg_stat()\pq", 'xt') + call assert_equal('a:', s:reg_stat) + call feedkeys("@a", 'xt') + call assert_equal(':a', s:reg_stat) + call feedkeys("qb@aq", 'xt') + call assert_equal('b:a', s:reg_stat) + call feedkeys("q\"\"=s:save_reg_stat()\pq", 'xt') + call assert_equal('":', s:reg_stat) + + bwipe! + delfunc s:save_reg_stat + unlet s:reg_stat +endfunc -- cgit 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/testdir/test_functions.vim | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/nvim/testdir/test_functions.vim') 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 From b2a11515b2cf6923dd0c1a36efe22aabf6bc582c Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 26 May 2019 20:56:33 -0400 Subject: vim-patch:8.1.1077: reg_executing() is reset by calling input() Problem: reg_executing() is reset by calling input(). Solution: Implement a more generic way to save and restore reg_executing. (Ozaki Kiichi, closes vim/vim#4192) https://github.com/vim/vim/commit/9a2c091a748b380efafe60583698c9afcaab1e46 --- src/nvim/testdir/test_functions.vim | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'src/nvim/testdir/test_functions.vim') diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index d58e4f8758..ed9c70403e 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -1103,20 +1103,38 @@ func Test_reg_executing_and_recording() " getchar() command saves and restores reg_executing map W :call TestFunc() let @q = "W" + let g:typed = '' + let g:regs = [] func TestFunc() abort - let g:reg1 = reg_executing() + let g:regs += [reg_executing()] let g:typed = getchar(0) - let g:reg2 = reg_executing() + let g:regs += [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) + call assert_equal(['q', 'q'], g:regs) delfunc TestFunc unmap W unlet g:typed - unlet g:reg1 - unlet g:reg2 + unlet g:regs + + " input() command saves and restores reg_executing + map W :call TestFunc() + let @q = "W" + let g:typed = '' + let g:regs = [] + func TestFunc() abort + let g:regs += [reg_executing()] + let g:typed = input('?') + let g:regs += [reg_executing()] + endfunc + call feedkeys("@qy\", 'xt') + call assert_equal("y", g:typed) + call assert_equal(['q', 'q'], g:regs) + delfunc TestFunc + unmap W + unlet g:typed + unlet g:regs bwipe! delfunc s:save_reg_stat -- cgit