mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-12-08 04:54:52 +08:00
Consistently handle missing command jobs across platforms
* On UNIX, jobs proceed normally, and exit with status 122. * On Windows, jobs fail early, and no callbacks run. * On Neovim, an exception is thrown. Normalize the second and third cases to behave like the first, as that was my assumed behavior during the initial implementation. References: https://github.com/tpope/vim-fugitive/issues/1815
This commit is contained in:
@@ -387,11 +387,15 @@ function! s:JobExecute(argv, jopts, stdin, callback, ...) abort
|
|||||||
\ 'stdout_buffered': v:true,
|
\ 'stdout_buffered': v:true,
|
||||||
\ 'stderr_buffered': v:true,
|
\ 'stderr_buffered': v:true,
|
||||||
\ 'on_exit': function('s:JobNvimExit', [dict, cb])})
|
\ 'on_exit': function('s:JobNvimExit', [dict, cb])})
|
||||||
let dict.job = jobstart(a:argv, a:jopts)
|
try
|
||||||
if !empty(a:stdin)
|
let dict.job = jobstart(a:argv, a:jopts)
|
||||||
call chansend(dict.job, a:stdin)
|
if !empty(a:stdin)
|
||||||
call chanclose(dict.job, 'stdin')
|
call chansend(dict.job, a:stdin)
|
||||||
endif
|
call chanclose(dict.job, 'stdin')
|
||||||
|
endif
|
||||||
|
catch /^Vim\%((\a\+)\)\=:E475:/
|
||||||
|
let [dict.exit_status, dict.stdout, dict.stderr] = [122, [''], ['']]
|
||||||
|
endtry
|
||||||
elseif exists('*ch_close_in')
|
elseif exists('*ch_close_in')
|
||||||
let temp = tempname()
|
let temp = tempname()
|
||||||
call extend(a:jopts, {
|
call extend(a:jopts, {
|
||||||
@@ -408,6 +412,10 @@ function! s:JobExecute(argv, jopts, stdin, callback, ...) abort
|
|||||||
call writefile(a:stdin, a:jopts.in_name, 'b')
|
call writefile(a:stdin, a:jopts.in_name, 'b')
|
||||||
endif
|
endif
|
||||||
let dict.job = job_start(a:argv, a:jopts)
|
let dict.job = job_start(a:argv, a:jopts)
|
||||||
|
if job_status(dict.job) ==# 'fail'
|
||||||
|
let [dict.exit_status, dict.stdout, dict.stderr] = [122, [''], ['']]
|
||||||
|
unlet dict.job
|
||||||
|
endif
|
||||||
elseif &shell !~# 'sh' || &shell =~# 'fish\|\%(powershell\|pwsh\)\%(\.exe\)\=$'
|
elseif &shell !~# 'sh' || &shell =~# 'fish\|\%(powershell\|pwsh\)\%(\.exe\)\=$'
|
||||||
throw 'fugitive: Vim 8 or higher required to use ' . &shell
|
throw 'fugitive: Vim 8 or higher required to use ' . &shell
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user