mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-15 23:03: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))
|
if has_key(s:temp_files, s:cpath(a:file))
|
||||||
let dict = s:temp_files[s:cpath(a:file)]
|
let dict = s:temp_files[s:cpath(a:file)]
|
||||||
setlocal nomodeline
|
setlocal nomodeline
|
||||||
|
if empty(&bufhidden)
|
||||||
setlocal bufhidden=delete
|
setlocal bufhidden=delete
|
||||||
|
endif
|
||||||
setlocal buftype=nowrite
|
setlocal buftype=nowrite
|
||||||
setlocal nomodifiable
|
setlocal nomodifiable
|
||||||
if len(dict.dir)
|
if len(dict.dir)
|
||||||
@@ -2269,10 +2271,20 @@ function! s:TempReadPost(file) abort
|
|||||||
return ''
|
return ''
|
||||||
endfunction
|
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
|
augroup fugitive_temp
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd BufReadPre * exe s:TempReadPre( expand('<amatch>:p'))
|
autocmd BufReadPre * exe s:TempReadPre( expand('<amatch>:p'))
|
||||||
autocmd BufReadPost * exe s:TempReadPost(expand('<amatch>:p'))
|
autocmd BufReadPost * exe s:TempReadPost(expand('<amatch>:p'))
|
||||||
|
autocmd BufWipeout * exe s:TempDelete( expand('<amatch>:p'))
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
" Section: :Git
|
" Section: :Git
|
||||||
|
|||||||
Reference in New Issue
Block a user