Merge pull request #239 from puremourning/togglelog

Add VimspectorToggleLog
This commit is contained in:
mergify[bot] 2020-08-28 13:42:56 +00:00 committed by GitHub
commit 7a8bdef088
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 56 additions and 3 deletions

View file

@ -33,6 +33,13 @@ work, please always include _all_ of the diagnostics requested in the
[issue template][issue-template]. Please do not be offended if your request
is ignored if it does not include the requested diagnostics.
The Vimspector log file contains a full trace of the communication between
Vimspector and the debug adapter. This is the primary source of diagnostic
information when something goes wrong that's not a clear Vim traceback.
If you just want to see the Vimspector log file, use `:VimspectorToggleLog`,
which will tail it in a little window (doesn't work on Windows).
## Issues
The GitHub issue tracker is for *bug reports* and *features requests* for the

View file

@ -42,6 +42,7 @@ For a tutorial and usage overview, take a look at the
* [Stack Traces](#stack-traces)
* [Program Output](#program-output)
* [Console](#console)
* [Log View](#log-view)
* [Closing debugger](#closing-debugger)
* [Debug adapter configuration](#debug-adapter-configuration)
* [C, C , Rust, etc.](#c-c-rust-etc)
@ -779,6 +780,15 @@ NOTE: See also [Watches](#watches) above.
If the output window is closed, a new one can be opened with
`:VimspectorShowOutput Console`.
### Log View
The Vimspector log file contains a full trace of the communication between
Vimspector and the debug adapter. This is the primary source of diagnostic
information when something goes wrong that's not a Vim traceback.
If you just want to see the Vimspector log file, use `:VimspectorToggleLog`,
which will tail it in a little window (doesn't work on Windows).
## Closing debugger
To close the debugger, use:

View file

@ -209,6 +209,13 @@ function! vimspector#ShowOutputInWindow( win_id, category ) abort
\ vim.eval( 'a:category' ) )
endfunction
function! vimspector#ToggleLog() abort
if !s:enabled
return
endif
py3 _vimspector_session.ToggleLog()
endfunction
function! vimspector#ListBreakpoints() abort
if !s:enabled
return

View file

@ -91,6 +91,9 @@ command! -bar -nargs=1 -complete=custom,vimspector#CompleteExpr
command! -bar -nargs=? -complete=custom,vimspector#CompleteOutput
\ VimspectorShowOutput
\ call vimspector#ShowOutput( <f-args> )
command! -bar
\ VimspectorToggleLog
\ call vimspector#ToggleLog()
command! -bar -nargs=1 -complete=custom,vimspector#CompleteExpr
\ VimspectorEval
\ call vimspector#Evaluate( <f-args> )

View file

@ -55,6 +55,7 @@ class DebugSession( object ):
install.GetGadgetDir( VIMSPECTOR_HOME ) )
self._uiTab = None
self._logView = None
self._stackTraceView = None
self._variablesView = None
self._outputView = None
@ -332,12 +333,15 @@ class DebugSession( object ):
return wrapper
return decorator
def _HasUI( self ):
return self._uiTab and self._uiTab.valid
def RequiresUI( otherwise=None ):
"""Decorator, call fct if self._connected else echo warning"""
def decorator( fct ):
@functools.wraps( fct )
def wrapper( self, *args, **kwargs ):
if not self._uiTab or not self._uiTab.valid:
if not self._HasUI():
utils.UserMessage(
'Vimspector is not active',
persist=False,
@ -492,6 +496,26 @@ class DebugSession( object ):
def ExpandFrameOrThread( self ):
self._stackTraceView.ExpandFrameOrThread()
def ToggleLog( self ):
if self._HasUI():
return self.ShowOutput( 'Vimspector' )
if self._logView and self._logView.WindowIsValid():
self._logView.Reset()
self._logView = None
return
if self._logView:
self._logView.Reset()
# TODO: The UI code is too scattered. Re-organise into a UI class that
# just deals with these thigns like window layout and custmisattion.
vim.command( f'botright { settings.Int( "bottombar_height", 10 ) }new' )
win = vim.current.window
self._logView = output.OutputView( win, self._api_prefix )
self._logView.AddLogFileView()
self._logView.ShowOutput( 'Vimspector' )
@RequiresUI()
def ShowOutput( self, category ):
if not self._outputView.WindowIsValid():

View file

@ -187,7 +187,6 @@ class OutputView( object ):
syntax,
self._buffers[ category ].buf )
def _RenderWinBar( self, category ):
if not self._window.valid:
return
@ -216,6 +215,9 @@ class OutputView( object ):
def GetCategories( self ):
return list( self._buffers.keys() )
def AddLogFileView( self, file_name = utils.LOG_FILE ):
self._CreateBuffer( 'Vimspector', file_name = file_name )
class DAPOutputView( OutputView ):
"""Specialised OutputView which adds the DAP Console (REPL)"""
@ -226,7 +228,7 @@ class DAPOutputView( OutputView ):
for b in set( BUFFER_MAP.values() ):
self._CreateBuffer( b )
self._CreateBuffer( 'Vimspector', file_name = utils.LOG_FILE )
self.AddLogFileView()
self._ShowOutput( 'Console' )
def ConnectionUp( self, connection ):