mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-08 11:33:47 -05:00
Don't record last job until after completion
This prevents orphaning a :Git commit when calling a second :Git command while editing the commit message, and is more predictable all around.
This commit is contained in:
@@ -2360,7 +2360,7 @@ endfunction
|
|||||||
|
|
||||||
function! s:TempDelete(file) abort
|
function! s:TempDelete(file) abort
|
||||||
let key = s:cpath(a:file)
|
let key = s:cpath(a:file)
|
||||||
if has_key(s:temp_files, key) && key !=# s:cpath(get(get(g:, '_fugitive_last_job', {}), 'file', ''))
|
if has_key(s:temp_files, key) && !has_key(s:temp_files[key], 'job') && key !=# s:cpath(get(get(g:, '_fugitive_last_job', {}), 'file', ''))
|
||||||
call delete(a:file)
|
call delete(a:file)
|
||||||
call remove(s:temp_files, key)
|
call remove(s:temp_files, key)
|
||||||
endif
|
endif
|
||||||
@@ -2393,14 +2393,14 @@ function! s:RunJobs() abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:RunSave(state) abort
|
function! s:RunSave(state) abort
|
||||||
if has_key(get(g:, '_fugitive_last_job', {}), 'file') && bufnr(g:_fugitive_last_job.file) < 0
|
|
||||||
exe s:TempDelete(remove(g:, '_fugitive_last_job').file)
|
|
||||||
endif
|
|
||||||
let g:_fugitive_last_job = a:state
|
|
||||||
let s:temp_files[s:cpath(a:state.file)] = a:state
|
let s:temp_files[s:cpath(a:state.file)] = a:state
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:RunFinished(state) abort
|
function! s:RunFinished(state) abort
|
||||||
|
if has_key(get(g:, '_fugitive_last_job', {}), 'file') && bufnr(g:_fugitive_last_job.file) < 0
|
||||||
|
exe s:TempDelete(remove(g:, '_fugitive_last_job').file)
|
||||||
|
endif
|
||||||
|
let g:_fugitive_last_job = a:state
|
||||||
let first = join(readfile(a:state.file, '', 2), "\n")
|
let first = join(readfile(a:state.file, '', 2), "\n")
|
||||||
if get(a:state, 'filetype', '') ==# 'git' && first =~# '\<\([[:upper:][:digit:]_-]\+(\d\+)\).*\1'
|
if get(a:state, 'filetype', '') ==# 'git' && first =~# '\<\([[:upper:][:digit:]_-]\+(\d\+)\).*\1'
|
||||||
let a:state.filetype = 'man'
|
let a:state.filetype = 'man'
|
||||||
|
|||||||
Reference in New Issue
Block a user