diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-02-18 21:54:41 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-02-18 21:54:41 +0100 |
commit | 406cd90f1963ca60813db91c413eef4b1b78ee44 (patch) | |
tree | 87c555c66bbfa8c3c2f4b8984e8d4463f0a79b0a /src/testdir/test_swap.vim | |
parent | 9e2bcb5d23138d45a0b6f9c1542b5facc807efe7 (diff) | |
download | vim-git-406cd90f1963ca60813db91c413eef4b1b78ee44.tar.gz |
patch 8.2.0275: some Ex code not covered by testsv8.2.0275
Problem: Some Ex code not covered by tests.
Solution: Add test cases. (Yegappan Lakshmanan, closes #5659)
Diffstat (limited to 'src/testdir/test_swap.vim')
-rw-r--r-- | src/testdir/test_swap.vim | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/src/testdir/test_swap.vim b/src/testdir/test_swap.vim index aa67b430e..7ce35ccae 100644 --- 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 |