From 68f570ec38352bb0ae918bd9bd7506544e59227b Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Sat, 7 Mar 2020 11:44:07 -0500 Subject: [PATCH] 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. --- autoload/fugitive.vim | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 0dacf28..a59ec5c 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -2303,13 +2303,24 @@ function! s:RunWait(state, job) abort if !exists('*jobwait') sleep 1m endif - let peek = getchar(1) - if peek != 0 && !(has('win32') && peek == 128) - let c = getchar() - let c = type(c) == type(0) ? nr2char(c) : c - call s:RunSend(a:job, c) - if !a:state.pty - echon c + 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 ==# "\" + 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