From 3643c2effd10515f29f80ba44878dfd941970a66 Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Sat, 11 Jul 2020 11:43:28 +0100 Subject: [PATCH] Only respond to data events for the _current_ job, not buffered data for old jobs --- autoload/vimspector/internal/job.vim | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/autoload/vimspector/internal/job.vim b/autoload/vimspector/internal/job.vim index 692f914..20a0560 100644 --- a/autoload/vimspector/internal/job.vim +++ b/autoload/vimspector/internal/job.vim @@ -20,7 +20,7 @@ set cpoptions&vim " }}} function! s:_OnServerData( channel, data ) abort - if !exists( 's:job' ) + if !exists( 's:job' ) || ch_getjob( a:channel ) isnot s:job call ch_log( 'Get data after process exit' ) return endif @@ -29,7 +29,7 @@ function! s:_OnServerData( channel, data ) abort endfunction function! s:_OnServerError( channel, data ) abort - if !exists( 's:job' ) + if !exists( 's:job' ) || ch_getjob( a:channel ) isnot s:job call ch_log( 'Get data after process exit' ) return endif @@ -37,7 +37,16 @@ function! s:_OnServerError( channel, data ) abort py3 _vimspector_session.OnServerStderr( vim.eval( 'a:data' ) ) endfunction + +" FIXME: We should wait until both the exit_cb _and_ the channel closed callback +" have been received before OnServerExit? + function! s:_OnExit( channel, status ) abort + if !exists( 's:job' ) || ch_getjob( a:channel ) isnot s:job + call ch_log( 'Unexpected exit callback' ) + return + endif + echom 'Channel exit with status ' . a:status redraw if exists( 's:job' ) @@ -47,6 +56,11 @@ function! s:_OnExit( channel, status ) abort endfunction function! s:_OnClose( channel ) abort + if !exists( 's:job' ) || job_getchannel( s:job ) != a:channel + call ch_log( 'Channel closed after exit' ) + return + endif + echom 'Channel closed' redraw endfunction