From e573c2fd9f7d4d5e7f77f78366cc366ecdd98146 Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Sat, 12 Jan 2019 15:12:52 +0000 Subject: [PATCH] Print server stderr to the GUI --- autoload/vimspector/internal/job.vim | 4 +++- python3/vimspector/debug_session.py | 5 +++++ python3/vimspector/output.py | 18 ++++++++++++------ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/autoload/vimspector/internal/job.vim b/autoload/vimspector/internal/job.vim index ef8058d..1a61a2b 100644 --- a/autoload/vimspector/internal/job.vim +++ b/autoload/vimspector/internal/job.vim @@ -26,7 +26,9 @@ EOF endfunction function! s:_OnServerError( channel, data ) abort - echom "Channel received error: " . a:data + py3 << EOF +_vimspector_session.OnServerStderr( vim.eval( 'a:data' ) ) +EOF endfunction function! s:_OnExit( channel, status ) abort diff --git a/python3/vimspector/debug_session.py b/python3/vimspector/debug_session.py index 7f11ab6..ec4b9b4 100644 --- a/python3/vimspector/debug_session.py +++ b/python3/vimspector/debug_session.py @@ -189,6 +189,11 @@ class DebugSession( object ): if self._connection: self._connection.OnData( data ) + def OnServerStderr( self, data ): + self._logger.info( "Server stderr: %s", data ) + if self._outputView: + self._outputView.ServerEcho( data ) + def OnRequestTimeout( self, timer_id ): if self._connection: self._connection.OnRequestTimeout( timer_id ) diff --git a/python3/vimspector/output.py b/python3/vimspector/output.py index 4bb40d3..439a583 100644 --- a/python3/vimspector/output.py +++ b/python3/vimspector/output.py @@ -42,19 +42,25 @@ class OutputView( object ): self.ShowOutput( 'Console' ) + def ServerEcho( self, text ): + self._Print( 'server', text.splitlines() ) + def OnOutput( self, event ): category = CategoryToBuffer( event.get( 'category' ) or 'output' ) + text_lines = event[ 'output' ].splitlines() + if 'data' in event: + text_lines.extend( json.dumps( event[ 'data' ], + indent = 2 ).splitlines() ) + + self._Print( category, text_lines ) + + def _Print( self, category, text_lines ): if category not in self._buffers: self._CreateBuffer( category ) buf = self._buffers[ category ] with utils.ModifiableScratchBuffer( buf ): - utils.AppendToBuffer( buf, event[ 'output' ].splitlines() ) - if 'data' in event: - utils.AppendToBuffer( buf, - json.dumps( event[ 'data' ], - indent = 2 ).splitlines() ) - + utils.AppendToBuffer( buf, text_lines ) # Scroll the buffer with utils.RestoreCurrentWindow():