static int
existing_swapfile(buf_T *buf)
{
- if (buf->b_ml.ml_mfp != NULL)
+ if (buf->b_ml.ml_mfp != NULL && buf->b_ml.ml_mfp->mf_fname != NULL)
{
char_u *fname = buf->b_ml.ml_mfp->mf_fname;
size_t len = STRLEN(fname);
call delete('Xresult')
endfunc
+" Test vimgrep without swap file
+func Test_vimgrep_without_swap_file()
+ let lines =<< trim [SCRIPT]
+ vimgrep grep test_c*
+ call writefile(['done'], 'Xresult')
+ qall!
+ [SCRIPT]
+ call writefile(lines, 'Xscript')
+ if RunVim([], [], '--clean -n -S Xscript Xscript')
+ call assert_equal(['done'], readfile('Xresult'))
+ endif
+ call delete('Xscript')
+ call delete('Xresult')
+endfunc
+
func Test_vimgrep_existing_swapfile()
call writefile(['match apple with apple'], 'Xapple')
call writefile(['swapfile'], '.Xapple.swp')