comparison src/testdir/test_functions.vim @ 15979:72987a858c96 v8.1.0995

patch 8.1.0995: a getchar() call resets the reg_executing() result commit https://github.com/vim/vim/commit/f0fab3046c2b5c4115979347464a802853011220 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Mar 5 12:24:10 2019 +0100 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 #406
author Bram Moolenaar <Bram@vim.org>
date Tue, 05 Mar 2019 12:30:08 +0100
parents 393a9a3a2da2
children 4850744dc181
comparison
equal deleted inserted replaced
15978:c036f95274c6 15979:72987a858c96
1136 call assert_equal('b:a', s:reg_stat) 1136 call assert_equal('b:a', s:reg_stat)
1137 call feedkeys("q\"\"=s:save_reg_stat()\<CR>pq", 'xt') 1137 call feedkeys("q\"\"=s:save_reg_stat()\<CR>pq", 'xt')
1138 call assert_equal('":', s:reg_stat) 1138 call assert_equal('":', s:reg_stat)
1139 1139
1140 " :normal command saves and restores reg_executing 1140 " :normal command saves and restores reg_executing
1141 let s:reg_stat = ''
1141 let @q = ":call TestFunc()\<CR>:call s:save_reg_stat()\<CR>" 1142 let @q = ":call TestFunc()\<CR>:call s:save_reg_stat()\<CR>"
1142 func TestFunc() abort 1143 func TestFunc() abort
1143 normal! ia 1144 normal! ia
1144 endfunc 1145 endfunc
1145 call feedkeys("@q", 'xt') 1146 call feedkeys("@q", 'xt')
1146 call assert_equal(':q', s:reg_stat) 1147 call assert_equal(':q', s:reg_stat)
1147 delfunc TestFunc 1148 delfunc TestFunc
1149
1150 " getchar() command saves and restores reg_executing
1151 map W :call TestFunc()<CR>
1152 let @q = "W"
1153 func TestFunc() abort
1154 let g:reg1 = reg_executing()
1155 let g:typed = getchar(0)
1156 let g:reg2 = reg_executing()
1157 endfunc
1158 call feedkeys("@qy", 'xt')
1159 call assert_equal(char2nr("y"), g:typed)
1160 call assert_equal('q', g:reg1)
1161 call assert_equal('q', g:reg2)
1162 delfunc TestFunc
1163 unmap W
1164 unlet g:typed
1165 unlet g:reg1
1166 unlet g:reg2
1148 1167
1149 bwipe! 1168 bwipe!
1150 delfunc s:save_reg_stat 1169 delfunc s:save_reg_stat
1151 unlet s:reg_stat 1170 unlet s:reg_stat
1152 endfunc 1171 endfunc