Mercurial > vim
comparison src/testdir/test_autocmd.vim @ 29471:9ada26920941 v9.0.0077
patch 9.0.0077: wrong restored cursor position when switching window in autocmd
Commit: https://github.com/vim/vim/commit/b03950fafa07e8b8d975eeb345ad08b8b62e67ce
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jul 26 13:47:13 2022 +0100
patch 9.0.0077: wrong restored cursor position when switching window in autocmd
Problem: When switching window in autocmd the restored cursor position may
be wrong.
Solution: Do not restore the cursor if it was not set. (closes #10775)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 26 Jul 2022 15:00:05 +0200 |
parents | 87da4bab5aaa |
children | 2a327999c05c |
comparison
equal
deleted
inserted
replaced
29470:513b1ece5ce2 | 29471:9ada26920941 |
---|---|
2315 | 2315 |
2316 augroup nested_inv | 2316 augroup nested_inv |
2317 au! | 2317 au! |
2318 augroup END | 2318 augroup END |
2319 set laststatus& | 2319 set laststatus& |
2320 cclose | |
2320 bwipe! | 2321 bwipe! |
2322 endfunc | |
2323 | |
2324 func Test_autocmd_nested_switch_window() | |
2325 " run this in a separate Vim so that SafeState works | |
2326 CheckRunVimInTerminal | |
2327 | |
2328 let lines =<< trim END | |
2329 vim9script | |
2330 ['()']->writefile('Xautofile') | |
2331 autocmd VimEnter * ++nested edit Xautofile | split | |
2332 autocmd BufReadPost * autocmd SafeState * ++once foldclosed('.') | |
2333 autocmd WinEnter * matchadd('ErrorMsg', 'pat') | |
2334 END | |
2335 call writefile(lines, 'Xautoscript') | |
2336 let buf = RunVimInTerminal('-S Xautoscript', {'rows': 10}) | |
2337 call VerifyScreenDump(buf, 'Test_autocmd_nested_switch', {}) | |
2338 | |
2339 call StopVimInTerminal(buf) | |
2340 call delete('Xautofile') | |
2341 call delete('Xautoscript') | |
2321 endfunc | 2342 endfunc |
2322 | 2343 |
2323 func Test_autocmd_once() | 2344 func Test_autocmd_once() |
2324 " Without ++once WinNew triggers twice | 2345 " Without ++once WinNew triggers twice |
2325 let g:did_split = 0 | 2346 let g:did_split = 0 |
2629 call delete('Xdir', 'rf') | 2650 call delete('Xdir', 'rf') |
2630 endfunc | 2651 endfunc |
2631 | 2652 |
2632 func Test_autocmd_SafeState() | 2653 func Test_autocmd_SafeState() |
2633 CheckRunVimInTerminal | 2654 CheckRunVimInTerminal |
2634 let g:test_is_flaky = 1 | |
2635 | 2655 |
2636 let lines =<< trim END | 2656 let lines =<< trim END |
2637 let g:safe = 0 | 2657 let g:safe = 0 |
2638 let g:again = '' | 2658 let g:again = '' |
2639 au SafeState * let g:safe += 1 | 2659 au SafeState * let g:safe += 1 |