Mercurial > vim
diff src/testdir/test_swap.vim @ 19435:8f8a5a15d00a v8.2.0275
patch 8.2.0275: some Ex code not covered by tests
Commit: https://github.com/vim/vim/commit/406cd90f1963ca60813db91c413eef4b1b78ee44
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Feb 18 21:54:41 2020 +0100
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 https://github.com/vim/vim/issues/5659)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 18 Feb 2020 22:00:04 +0100 |
parents | f6dcf7eabd26 |
children | 0aba9ef12488 |
line wrap: on
line diff
--- a/src/testdir/test_swap.vim +++ b/src/testdir/test_swap.vim @@ -277,7 +277,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']) @@ -309,3 +308,45 @@ func Test_swap_recover_ext() augroup END 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 + +" vim: shiftwidth=2 sts=2 expandtab