Enable closing stdin by pressing CTRL-D

This provides a way to use commands like :Git hash-object --stdin
without a PTY, which is not to say that there are any such commands that
one would actually want to use.  It also has debugging applications.
This commit is contained in:
Tim Pope
2020-03-07 11:44:07 -05:00
parent 12e43b62cc
commit 68f570ec38

View File

@@ -2303,15 +2303,26 @@ function! s:RunWait(state, job) abort
if !exists('*jobwait')
sleep 1m
endif
if !get(a:state, 'closed')
let peek = getchar(1)
if peek != 0 && !(has('win32') && peek == 128)
let c = getchar()
let c = type(c) == type(0) ? nr2char(c) : c
if c ==# "\<C-D>"
let a:state.closed = 1
if type(a:job) ==# type(0)
call chanclose(a:job, 'stdin')
else
call ch_close_in(a:job)
endif
else
call s:RunSend(a:job, c)
if !a:state.pty
echon c
endif
endif
endif
endif
endwhile
sleep 1m
echo