diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2019-04-29 17:41:17 +0200 |
|---|---|---|
| committer | Justin M. Keyes <justinkz@gmail.com> | 2019-04-29 21:22:55 +0200 |
| commit | 3033b5a70a1a9f1fdce1a772541fec9722825298 (patch) | |
| tree | d75910dd59df01772559b8327e88939744c19793 /src/nvim/testdir | |
| parent | 04f0bc97b732c395dbfcc9411910ab58b9346f58 (diff) | |
| download | rneovim-3033b5a70a1a9f1fdce1a772541fec9722825298.tar.gz rneovim-3033b5a70a1a9f1fdce1a772541fec9722825298.tar.bz2 rneovim-3033b5a70a1a9f1fdce1a772541fec9722825298.zip | |
vim-patch:8.1.1231: asking about existing swap file unnecessarily
Problem: Asking about existing swap file unnecessarily.
Solution: When it is safe, delete the swap file. Remove
HAS_SWAP_EXISTS_ACTION, it is always defined. (closes vim/vim#1237)
https://github.com/vim/vim/commit/67cf86bfff5fd5224d557d81cb146f46e33b831c
N/A:
vim-patch:8.1.1232
vim-patch:8.1.1233
vim-patch:8.1.1236
Diffstat (limited to 'src/nvim/testdir')
| -rw-r--r-- | src/nvim/testdir/test_swap.vim | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_swap.vim b/src/nvim/testdir/test_swap.vim index 1bd73707a8..1000422813 100644 --- a/src/nvim/testdir/test_swap.vim +++ b/src/nvim/testdir/test_swap.vim @@ -125,3 +125,59 @@ func Test_swapname() call delete('Xtest2') call delete('Xtest3') endfunc + +func Test_swapfile_delete() + autocmd! SwapExists + function s:swap_exists() + let v:swapchoice = s:swap_choice + let s:swapname = v:swapname + let s:filename = expand('<afile>') + endfunc + augroup test_swapfile_delete + autocmd! + autocmd SwapExists * call s:swap_exists() + augroup END + + + " Create a valid swapfile by editing a file. + split XswapfileText + call setline(1, ['one', 'two', 'three']) + write " file is written, not modified + " read the swapfile as a Blob + let swapfile_name = swapname('%') + let swapfile_bytes = readfile(swapfile_name, 'B') + + " Close the file and recreate the swap file. + " Now editing the file will run into the process still existing + quit + call writefile(swapfile_bytes, swapfile_name) + let s:swap_choice = 'e' + let s:swapname = '' + split XswapfileText + quit + call assert_equal(swapfile_name, s:swapname) + + " Write the swapfile with a modified PID, now it will be automatically + " deleted. Process one should never be Vim. + let swapfile_bytes[24:27] = 0z01000000 + call writefile(swapfile_bytes, swapfile_name) + let s:swapname = '' + split XswapfileText + quit + call assert_equal('', s:swapname) + + " Now set the modified flag, the swap file will not be deleted + let swapfile_bytes[28 + 80 + 899] = 0x55 + call writefile(swapfile_bytes, swapfile_name) + let s:swapname = '' + split XswapfileText + quit + call assert_equal(swapfile_name, s:swapname) + + call delete('XswapfileText') + call delete(swapfile_name) + augroup test_swapfile_delete + autocmd! + augroup END + augroup! test_swapfile_delete +endfunc |