From 89d77870e7e72336c7e1ab68332db681c0cda52f Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Tue, 1 Sep 2020 09:53:44 +0100 Subject: [PATCH] WIP: Attempt to make restart work for CodeLLDB by flushing the channel on closedown - doesn't --- autoload/vimspector/internal/channel.vim | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/autoload/vimspector/internal/channel.vim b/autoload/vimspector/internal/channel.vim index b05d8e8..3fe524f 100644 --- a/autoload/vimspector/internal/channel.vim +++ b/autoload/vimspector/internal/channel.vim @@ -94,6 +94,16 @@ _vimspector_session.OnRequestTimeout( vim.eval( 'a:id' ) ) EOF endfunction +function! s:KillJob() abort + if exists( 's:job' ) + if job_status( s:job ) ==# 'run' + call job_stop( s:job, 'kill' ) + endif + unlet s:job + sleep 500m + endif +endfunction + function! vimspector#internal#channel#StopDebugSession() abort if exists( 's:ch' ) && ch_status( s:ch ) ==# 'open' " channel is open, close it and trigger the callback. The callback is _not_ @@ -101,15 +111,17 @@ function! vimspector#internal#channel#StopDebugSession() abort " is not open, then we there is a _OnClose callback waiting for us, so do " nothing. call ch_close( s:ch ) + while ch_status( s:ch ) ==# 'buffered' + let data = ch_read( s:ch, {'timeout': 0} ) + if data == '' + continue + endif + call s:_OnServerData( s:ch, data ) + endwhile call s:_OnClose( s:ch ) endif - if exists( 's:job' ) - if job_status( s:job ) ==# 'run' - call job_stop( s:job, 'kill' ) - endif - unlet s:job - endif + call s:KillJob() endfunction function! vimspector#internal#channel#Reset() abort