mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-15 06:43:51 -05:00
Delete backing temp file upon wiping buffer
We should probably default buftype to wipe so that these don't stack up indefinitely by default, but one step at a time.
This commit is contained in:
@@ -2241,7 +2241,9 @@ function! s:TempReadPre(file) abort
|
||||
if has_key(s:temp_files, s:cpath(a:file))
|
||||
let dict = s:temp_files[s:cpath(a:file)]
|
||||
setlocal nomodeline
|
||||
setlocal bufhidden=delete
|
||||
if empty(&bufhidden)
|
||||
setlocal bufhidden=delete
|
||||
endif
|
||||
setlocal buftype=nowrite
|
||||
setlocal nomodifiable
|
||||
if len(dict.dir)
|
||||
@@ -2269,10 +2271,20 @@ function! s:TempReadPost(file) abort
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! s:TempDelete(file) abort
|
||||
let key = s:cpath(a:file)
|
||||
if has_key(s:temp_files, key)
|
||||
call delete(a:file)
|
||||
call remove(s:temp_files, key)
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
augroup fugitive_temp
|
||||
autocmd!
|
||||
autocmd BufReadPre * exe s:TempReadPre( expand('<amatch>:p'))
|
||||
autocmd BufReadPost * exe s:TempReadPost(expand('<amatch>:p'))
|
||||
autocmd BufWipeout * exe s:TempDelete( expand('<amatch>:p'))
|
||||
augroup END
|
||||
|
||||
" Section: :Git
|
||||
|
||||
Reference in New Issue
Block a user