Allow 'channel' based transports to also start a job
This commit is contained in:
parent
596ea65ca6
commit
b322a2e89c
2 changed files with 24 additions and 8 deletions
|
|
@ -39,6 +39,21 @@ function! vimspector#internal#channel#StartDebugSession( config ) abort
|
||||||
return v:false
|
return v:false
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" If we _also_ have a command line, then start the actual job. This allows for
|
||||||
|
" servers which start up and listen on some port
|
||||||
|
if has_key( a:config, 'command' )
|
||||||
|
let s:job = job_start( a:config[ 'command' ],
|
||||||
|
\ {
|
||||||
|
\ 'in_mode': 'raw',
|
||||||
|
\ 'out_mode': 'raw',
|
||||||
|
\ 'err_mode': 'raw',
|
||||||
|
\ 'stoponexit': 'term',
|
||||||
|
\ 'env': a:config[ 'env' ],
|
||||||
|
\ 'cwd': a:config[ 'cwd' ],
|
||||||
|
\ }
|
||||||
|
\ )
|
||||||
|
endif
|
||||||
|
|
||||||
let l:addr = get( a:config, 'host', 'localhost' ) . ':' . a:config[ 'port' ]
|
let l:addr = get( a:config, 'host', 'localhost' ) . ':' . a:config[ 'port' ]
|
||||||
|
|
||||||
echo 'Connecting to ' . l:addr . '... (waiting fo up to 10 seconds)'
|
echo 'Connecting to ' . l:addr . '... (waiting fo up to 10 seconds)'
|
||||||
|
|
@ -72,11 +87,7 @@ EOF
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! vimspector#internal#channel#StopDebugSession() abort
|
function! vimspector#internal#channel#StopDebugSession() abort
|
||||||
if !exists( 's:ch' )
|
if exists( 's:ch' ) && ch_status( s:ch ) ==# 'open'
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
if ch_status( s:ch ) ==# 'open'
|
|
||||||
" channel is open, close it and trigger the callback. The callback is _not_
|
" channel is open, close it and trigger the callback. The callback is _not_
|
||||||
" triggered when manually calling ch_close. if we get here and the channel
|
" triggered when manually calling ch_close. if we get here and the channel
|
||||||
" is not open, then we there is a _OnClose callback waiting for us, so do
|
" is not open, then we there is a _OnClose callback waiting for us, so do
|
||||||
|
|
@ -84,10 +95,15 @@ function! vimspector#internal#channel#StopDebugSession() abort
|
||||||
call ch_close( s:ch )
|
call ch_close( s:ch )
|
||||||
call s:_OnClose( s:ch )
|
call s:_OnClose( s:ch )
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if exists( 's:job' ) && job_status( s:job ) ==# 'run'
|
||||||
|
call job_stop( s:job, 'kill' )
|
||||||
|
unlet s:job
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! vimspector#internal#channel#Reset() abort
|
function! vimspector#internal#channel#Reset() abort
|
||||||
if exists( 's:ch' )
|
if exists( 's:ch' ) || exists( 's:job' )
|
||||||
call vimspector#internal#channel#StopDebugSession()
|
call vimspector#internal#channel#StopDebugSession()
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
|
||||||
|
|
@ -128,8 +128,8 @@ function! vimspector#internal#job#StopDebugSession() abort
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if job_status( s:job ) ==# 'run'
|
if job_status( s:job ) ==# 'run'
|
||||||
echom 'Terminating job'
|
echom 'Terminating job'
|
||||||
redraw
|
redraw
|
||||||
call job_stop( s:job, 'kill' )
|
call job_stop( s:job, 'kill' )
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue