Skip to content

Commit 66a921b

Browse files
committed
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: #1815
1 parent 2357068 commit 66a921b

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

autoload/fugitive.vim

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -387,11 +387,15 @@ function! s:JobExecute(argv, jopts, stdin, callback, ...) abort
387387
\ 'stdout_buffered': v:true,
388388
\ 'stderr_buffered': v:true,
389389
\ 'on_exit': function('s:JobNvimExit', [dict, cb])})
390-
let dict.job = jobstart(a:argv, a:jopts)
391-
if !empty(a:stdin)
392-
call chansend(dict.job, a:stdin)
393-
call chanclose(dict.job, 'stdin')
394-
endif
390+
try
391+
let dict.job = jobstart(a:argv, a:jopts)
392+
if !empty(a:stdin)
393+
call chansend(dict.job, a:stdin)
394+
call chanclose(dict.job, 'stdin')
395+
endif
396+
catch /^Vim\%((\a\+)\)\=:E475:/
397+
let [dict.exit_status, dict.stdout, dict.stderr] = [122, [''], ['']]
398+
endtry
395399
elseif exists('*ch_close_in')
396400
let temp = tempname()
397401
call extend(a:jopts, {
@@ -408,6 +412,10 @@ function! s:JobExecute(argv, jopts, stdin, callback, ...) abort
408412
call writefile(a:stdin, a:jopts.in_name, 'b')
409413
endif
410414
let dict.job = job_start(a:argv, a:jopts)
415+
if job_status(dict.job) ==# 'fail'
416+
let [dict.exit_status, dict.stdout, dict.stderr] = [122, [''], ['']]
417+
unlet dict.job
418+
endif
411419
elseif &shell !~# 'sh' || &shell =~# 'fish\|\%(powershell\|pwsh\)\%(\.exe\)\=$'
412420
throw 'fugitive: Vim 8 or higher required to use ' . &shell
413421
else

0 commit comments

Comments
 (0)