Ignore E302 "Could not rename swap file" error

According to `:help E302`, E302 comes from Vim being unable to rename
the swap file when an open buffer's name is changed; but the error is
mostly harmless. E302 seems to occur in vim-fugitive under Windows but
not *nix.

This fix allow :Glog and :Gdiff to work on such systems; previously the
uncaught error made these operations fail or at least work strangely.
This commit is contained in:
Eric Christopherson
2014-04-09 21:55:34 -05:00
committed by Tim Pope
parent e6e259c2d2
commit 269c89ef59

View File

@@ -2078,7 +2078,10 @@ function! s:ReplaceCmd(cmd,...) abort
try
silent edit!
finally
silent exe 'keepalt file '.s:fnameescape(fn)
try
silent exe 'keepalt file '.s:fnameescape(fn)
catch /^Vim\%((\a\+)\)\=:E302/
endtry
call delete(tmp)
if fnamemodify(bufname('$'), ':p') ==# tmp
silent execute 'bwipeout '.bufnr('$')