diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2022-07-12 13:28:17 +0800 |
|---|---|---|
| committer | zeertzjq <zeertzjq@outlook.com> | 2022-07-12 16:23:32 +0800 |
| commit | 01afd43bc90408b43db906845245a4959c8ee3a0 (patch) | |
| tree | 2386f072c52f5130d6ed83e33919dcd192f07b75 /src/nvim/testdir/test_swap.vim | |
| parent | 0f1b17788eb584f41d59c12c968f5e1886655334 (diff) | |
| download | rneovim-01afd43bc90408b43db906845245a4959c8ee3a0.tar.gz rneovim-01afd43bc90408b43db906845245a4959c8ee3a0.tar.bz2 rneovim-01afd43bc90408b43db906845245a4959c8ee3a0.zip | |
vim-patch:8.2.0275: some Ex code not covered by tests
Problem: Some Ex code not covered by tests.
Solution: Add test cases. (Yegappan Lakshmanan, closes vim/vim#5659)
https://github.com/vim/vim/commit/406cd90f1963ca60813db91c413eef4b1b78ee44
Diffstat (limited to 'src/nvim/testdir/test_swap.vim')
| -rw-r--r-- | src/nvim/testdir/test_swap.vim | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/src/nvim/testdir/test_swap.vim b/src/nvim/testdir/test_swap.vim index b180f27685..923e1cbf50 100644 --- a/src/nvim/testdir/test_swap.vim +++ b/src/nvim/testdir/test_swap.vim @@ -278,7 +278,6 @@ func Test_swap_recover_ext() autocmd SwapExists * let v:swapchoice = 'r' augroup END - " Create a valid swapfile by editing a file with a special extension. split Xtest.scr call setline(1, ['one', 'two', 'three']) @@ -311,6 +310,46 @@ func Test_swap_recover_ext() augroup! test_swap_recover_ext endfunc +" Test for closing a split window automatically when a swap file is detected +" and 'Q' is selected in the confirmation prompt. +func Test_swap_split_win() + autocmd! SwapExists + augroup test_swap_splitwin + autocmd! + autocmd SwapExists * let v:swapchoice = 'q' + augroup END + + " Create a valid swapfile by editing a file with a special extension. + split Xtest.scr + call setline(1, ['one', 'two', 'three']) + write " file is written, not modified + write " write again to make sure the swapfile is created + " read the swapfile as a Blob + let swapfile_name = swapname('%') + let swapfile_bytes = readfile(swapfile_name, 'B') + + " Close and delete the file and recreate the swap file. + quit + call delete('Xtest.scr') + call writefile(swapfile_bytes, swapfile_name) + " Split edit the file again. This should fail to open the window + try + split Xtest.scr + catch + " E308 should be caught, not E306. + call assert_exception('E308:') " Original file may have been changed + endtry + call assert_equal(1, winnr('$')) + + call delete('Xtest.scr') + call delete(swapfile_name) + + augroup test_swap_splitwin + autocmd! + augroup END + augroup! test_swap_splitwin +endfunc + " Test for selecting 'q' in the attention prompt func Test_swap_prompt_splitwin() CheckRunVimInTerminal |