Delete batchfile only if it exists (#901)

Close #900
This commit is contained in:
Jan Edmund Lazo 2019-11-03 21:10:37 -05:00 committed by GitHub
parent eee50c55bf
commit 68fef9c2fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -822,6 +822,7 @@ function! s:chsh(swap)
endfunction endfunction
function! s:bang(cmd, ...) function! s:bang(cmd, ...)
let batchfile = ''
try try
let [sh, shellcmdflag, shrd] = s:chsh(a:0) let [sh, shellcmdflag, shrd] = s:chsh(a:0)
" FIXME: Escaping is incomplete. We could use shellescape with eval, " FIXME: Escaping is incomplete. We could use shellescape with eval,
@ -835,7 +836,7 @@ function! s:bang(cmd, ...)
finally finally
unlet g:_plug_bang unlet g:_plug_bang
let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd] let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd]
if s:is_win if s:is_win && filereadable(batchfile)
call delete(batchfile) call delete(batchfile)
endif endif
endtry endtry
@ -2047,6 +2048,7 @@ function! s:with_cd(cmd, dir, ...)
endfunction endfunction
function! s:system(cmd, ...) function! s:system(cmd, ...)
let batchfile = ''
try try
let [sh, shellcmdflag, shrd] = s:chsh(1) let [sh, shellcmdflag, shrd] = s:chsh(1)
let cmd = a:0 > 0 ? s:with_cd(a:cmd, a:1) : a:cmd let cmd = a:0 > 0 ? s:with_cd(a:cmd, a:1) : a:cmd
@ -2056,7 +2058,7 @@ function! s:system(cmd, ...)
return system(cmd) return system(cmd)
finally finally
let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd] let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd]
if s:is_win if s:is_win && filereadable(batchfile)
call delete(batchfile) call delete(batchfile)
endif endif
endtry endtry
@ -2379,6 +2381,7 @@ function! s:preview_commit()
wincmd P wincmd P
endif endif
setlocal previewwindow filetype=git buftype=nofile nobuflisted modifiable setlocal previewwindow filetype=git buftype=nofile nobuflisted modifiable
let batchfile = ''
try try
let [sh, shellcmdflag, shrd] = s:chsh(1) let [sh, shellcmdflag, shrd] = s:chsh(1)
let cmd = 'cd '.plug#shellescape(g:plugs[name].dir).' && git show --no-color --pretty=medium '.sha let cmd = 'cd '.plug#shellescape(g:plugs[name].dir).' && git show --no-color --pretty=medium '.sha
@ -2388,7 +2391,7 @@ function! s:preview_commit()
execute 'silent %!' cmd execute 'silent %!' cmd
finally finally
let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd] let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd]
if s:is_win if s:is_win && filereadable(batchfile)
call delete(batchfile) call delete(batchfile)
endif endif
endtry endtry