@@ -2,6 +2,8 @@ if !has('nvim')
2
2
import autoload ' tpipeline/parse.vim'
3
3
endif
4
4
5
+ let s: exit_code = -1
6
+
5
7
func tpipeline#get_filepath ()
6
8
" e.g. /tmp/tmux-1000/default-$0-vimbridge
7
9
let tmux = $TMUX
@@ -140,6 +142,16 @@ func tpipeline#initialize()
140
142
augroup END
141
143
endfunc
142
144
145
+ func tpipeline#on_exit (job, code, t )
146
+ call tpipeline#state#freeze ()
147
+ let s: exit_code = a: code
148
+ endfunc
149
+
150
+ func tpipeline#exit_cb (job, code)
151
+ call tpipeline#state#freeze ()
152
+ let s: exit_code = a: code
153
+ endfunc
154
+
143
155
func tpipeline#fork_job ()
144
156
if g: tpipeline_restore
145
157
let s: restore_left = systemlist (" sh -c 'echo \"\" ; tmux display-message -p \" #{status-left}\" '" )[-1 ]
@@ -171,10 +183,11 @@ func tpipeline#fork_job()
171
183
172
184
let command = [' bash' , ' -c' , script ]
173
185
if s: is_nvim
174
- let s: job = jobstart (command )
186
+ let options = #{on_exit: function (' tpipeline#on_exit' )}
187
+ let s: job = jobstart (command , options )
175
188
let s: channel = s: job
176
189
else
177
- let options = #{noblock: 1 }
190
+ let options = #{noblock: 1 , exit_c b: function ( ' tpipeline#exit_cb ' ) }
178
191
let s: job = job_start (command , options )
179
192
let s: channel = job_getchannel (s: job )
180
193
endif
@@ -320,6 +333,9 @@ func tpipeline#job_state()
320
333
else
321
334
let res = job_status (s: job )
322
335
endif
336
+ if s: exit_code > -1
337
+ let res .= printf (" (exit code %d)" , s: exit_code )
338
+ endif
323
339
324
340
return res
325
341
endfunc
0 commit comments