|
2 | 2 |
|
3 | 3 | source shared.vim |
4 | 4 | source check.vim |
| 5 | +source term_util.vim |
5 | 6 |
|
6 | 7 | func s:cleanup_buffers() abort |
7 | 8 | for bnr in range(1, bufnr('$')) |
@@ -2225,3 +2226,33 @@ func Test_throw_in_BufWritePre() |
2225 | 2226 | bwipe! |
2226 | 2227 | au! throwing |
2227 | 2228 | endfunc |
| 2229 | + |
| 2230 | +func Test_autocmd_SafeState() |
| 2231 | + CheckRunVimInTerminal |
| 2232 | + |
| 2233 | + let lines =<< trim END |
| 2234 | + let g:safe = 0 |
| 2235 | + let g:again = '' |
| 2236 | + au SafeState * let g:safe += 1 |
| 2237 | + au SafeStateAgain * let g:again ..= 'x' |
| 2238 | + func CallTimer() |
| 2239 | + call timer_start(10, {id -> execute('let g:again ..= "t"')}) |
| 2240 | + endfunc |
| 2241 | + END |
| 2242 | + call writefile(lines, 'XSafeState') |
| 2243 | + let buf = RunVimInTerminal('-S XSafeState', #{rows: 6}) |
| 2244 | + |
| 2245 | + call term_sendkeys(buf, ":echo g:safe\<CR>") |
| 2246 | + call WaitForAssert({-> assert_match('^2 ', term_getline(buf, 6))}, 1000) |
| 2247 | + |
| 2248 | + call term_sendkeys(buf, ":echo g:again\<CR>") |
| 2249 | + call WaitForAssert({-> assert_match('^xxxx', term_getline(buf, 6))}, 1000) |
| 2250 | + |
| 2251 | + call term_sendkeys(buf, ":let g:again = ''\<CR>:call CallTimer()\<CR>") |
| 2252 | + call term_wait(buf) |
| 2253 | + call term_sendkeys(buf, ":echo g:again\<CR>") |
| 2254 | + call WaitForAssert({-> assert_match('xtx', term_getline(buf, 6))}, 1000) |
| 2255 | + |
| 2256 | + call StopVimInTerminal(buf) |
| 2257 | + call delete('XSafeState') |
| 2258 | +endfunc |
0 commit comments