mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-14 22:33:51 -05:00
Handle race condition closing job stdin
This race condition is there for any key press, but it's greatly exaggerated by Vim's default one second timeout on Escape. This delay also disqualifies Escape as the official interface to this feature, but leave it as a DWIM alternative to CTRL-D for now. Closes https://github.com/tpope/vim-fugitive/issues/1722
This commit is contained in:
@@ -2566,6 +2566,19 @@ function! s:RunSend(job, str) abort
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! s:RunCloseIn(job) abort
|
||||
try
|
||||
if type(a:job) ==# type(0)
|
||||
call chanclose(a:job, 'stdin')
|
||||
else
|
||||
call ch_close_in(a:job)
|
||||
endif
|
||||
return 1
|
||||
catch /^Vim\%((\a\+)\)\=:E90[06]:/
|
||||
return 0
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! s:RunEcho(tmp) abort
|
||||
if !has_key(a:tmp, 'echo')
|
||||
return
|
||||
@@ -2605,12 +2618,7 @@ function! s:RunWait(state, tmp, job, ...) abort
|
||||
let c = type(c) == type(0) ? nr2char(c) : c
|
||||
if c ==# "\<C-D>" || c ==# "\<Esc>"
|
||||
let a:state.closed_in = 1
|
||||
if type(a:job) ==# type(0)
|
||||
call chanclose(a:job, 'stdin')
|
||||
else
|
||||
call ch_close_in(a:job)
|
||||
endif
|
||||
let can_pedit = exists('*setbufline')
|
||||
let can_pedit = s:RunCloseIn(a:job) && exists('*setbufline')
|
||||
for winnr in range(1, winnr('$'))
|
||||
if getwinvar(winnr, '&previewwindow') && getbufvar(winbufnr(winnr), '&modified')
|
||||
let can_pedit = 0
|
||||
|
||||
Reference in New Issue
Block a user