patch 8.2.1384: no ATTENTION prompt for :vimgrep first match file
Problem: No ATTENTION prompt for :vimgrep first match file.
Solution: When there is an existing swap file do not keep the dummy buffer.
(closes #6649)
diff --git a/src/testdir/runtest.vim b/src/testdir/runtest.vim
index f3609f8..f431748 100644
--- a/src/testdir/runtest.vim
+++ b/src/testdir/runtest.vim
@@ -91,6 +91,9 @@
let s:test_script_fname = expand('%')
au! SwapExists * call HandleSwapExists()
func HandleSwapExists()
+ if exists('g:ignoreSwapExists')
+ return
+ endif
" Ignore finding a swap file for the test script (the user might be
" editing it and do ":make test_name") and the output file.
" Report finding another swap file and chose 'q' to avoid getting stuck.
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim
index 8ca5578..e71a3df 100644
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -2837,6 +2837,26 @@
call delete('Xresult')
endfunc
+func Test_vimgrep_existing_swapfile()
+ call writefile(['match apple with apple'], 'Xapple')
+ call writefile(['swapfile'], '.Xapple.swp')
+ let g:foundSwap = 0
+ let g:ignoreSwapExists = 1
+ augroup grep
+ au SwapExists * let foundSwap = 1 | let v:swapchoice = 'e'
+ augroup END
+ vimgrep apple Xapple
+ call assert_equal(1, g:foundSwap)
+ call assert_match('.Xapple.swo', swapname(''))
+
+ call delete('Xapple')
+ call delete('Xapple.swp')
+ augroup grep
+ au! SwapExists
+ augroup END
+ unlet g:ignoreSwapExists
+endfunc
+
func XfreeTests(cchar)
call s:setup_commands(a:cchar)