Add VimspectorToggleLog
This commit is contained in:
parent
3374d32891
commit
51cc6c4d3a
6 changed files with 56 additions and 3 deletions
|
|
@ -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
|
[issue template][issue-template]. Please do not be offended if your request
|
||||||
is ignored if it does not include the requested diagnostics.
|
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
|
## Issues
|
||||||
|
|
||||||
The GitHub issue tracker is for *bug reports* and *features requests* for the
|
The GitHub issue tracker is for *bug reports* and *features requests* for the
|
||||||
|
|
|
||||||
10
README.md
10
README.md
|
|
@ -42,6 +42,7 @@ For a tutorial and usage overview, take a look at the
|
||||||
* [Stack Traces](#stack-traces)
|
* [Stack Traces](#stack-traces)
|
||||||
* [Program Output](#program-output)
|
* [Program Output](#program-output)
|
||||||
* [Console](#console)
|
* [Console](#console)
|
||||||
|
* [Log View](#log-view)
|
||||||
* [Closing debugger](#closing-debugger)
|
* [Closing debugger](#closing-debugger)
|
||||||
* [Debug adapter configuration](#debug-adapter-configuration)
|
* [Debug adapter configuration](#debug-adapter-configuration)
|
||||||
* [C, C , Rust, etc.](#c-c-rust-etc)
|
* [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
|
If the output window is closed, a new one can be opened with
|
||||||
`:VimspectorShowOutput Console`.
|
`: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
|
## Closing debugger
|
||||||
|
|
||||||
To close the debugger, use:
|
To close the debugger, use:
|
||||||
|
|
|
||||||
|
|
@ -209,6 +209,13 @@ function! vimspector#ShowOutputInWindow( win_id, category ) abort
|
||||||
\ vim.eval( 'a:category' ) )
|
\ vim.eval( 'a:category' ) )
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! vimspector#ToggleLog() abort
|
||||||
|
if !s:enabled
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
py3 _vimspector_session.ToggleLog()
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! vimspector#ListBreakpoints() abort
|
function! vimspector#ListBreakpoints() abort
|
||||||
if !s:enabled
|
if !s:enabled
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,9 @@ command! -bar -nargs=1 -complete=custom,vimspector#CompleteExpr
|
||||||
command! -bar -nargs=? -complete=custom,vimspector#CompleteOutput
|
command! -bar -nargs=? -complete=custom,vimspector#CompleteOutput
|
||||||
\ VimspectorShowOutput
|
\ VimspectorShowOutput
|
||||||
\ call vimspector#ShowOutput( <f-args> )
|
\ call vimspector#ShowOutput( <f-args> )
|
||||||
|
command! -bar
|
||||||
|
\ VimspectorToggleLog
|
||||||
|
\ call vimspector#ToggleLog()
|
||||||
command! -bar -nargs=1 -complete=custom,vimspector#CompleteExpr
|
command! -bar -nargs=1 -complete=custom,vimspector#CompleteExpr
|
||||||
\ VimspectorEval
|
\ VimspectorEval
|
||||||
\ call vimspector#Evaluate( <f-args> )
|
\ call vimspector#Evaluate( <f-args> )
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ class DebugSession( object ):
|
||||||
install.GetGadgetDir( VIMSPECTOR_HOME ) )
|
install.GetGadgetDir( VIMSPECTOR_HOME ) )
|
||||||
|
|
||||||
self._uiTab = None
|
self._uiTab = None
|
||||||
|
self._logView = None
|
||||||
self._stackTraceView = None
|
self._stackTraceView = None
|
||||||
self._variablesView = None
|
self._variablesView = None
|
||||||
self._outputView = None
|
self._outputView = None
|
||||||
|
|
@ -332,12 +333,15 @@ class DebugSession( object ):
|
||||||
return wrapper
|
return wrapper
|
||||||
return decorator
|
return decorator
|
||||||
|
|
||||||
|
def _HasUI( self ):
|
||||||
|
return self._uiTab and self._uiTab.valid
|
||||||
|
|
||||||
def RequiresUI( otherwise=None ):
|
def RequiresUI( otherwise=None ):
|
||||||
"""Decorator, call fct if self._connected else echo warning"""
|
"""Decorator, call fct if self._connected else echo warning"""
|
||||||
def decorator( fct ):
|
def decorator( fct ):
|
||||||
@functools.wraps( fct )
|
@functools.wraps( fct )
|
||||||
def wrapper( self, *args, **kwargs ):
|
def wrapper( self, *args, **kwargs ):
|
||||||
if not self._uiTab or not self._uiTab.valid:
|
if not self._HasUI():
|
||||||
utils.UserMessage(
|
utils.UserMessage(
|
||||||
'Vimspector is not active',
|
'Vimspector is not active',
|
||||||
persist=False,
|
persist=False,
|
||||||
|
|
@ -492,6 +496,26 @@ class DebugSession( object ):
|
||||||
def ExpandFrameOrThread( self ):
|
def ExpandFrameOrThread( self ):
|
||||||
self._stackTraceView.ExpandFrameOrThread()
|
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()
|
@RequiresUI()
|
||||||
def ShowOutput( self, category ):
|
def ShowOutput( self, category ):
|
||||||
if not self._outputView.WindowIsValid():
|
if not self._outputView.WindowIsValid():
|
||||||
|
|
|
||||||
|
|
@ -187,7 +187,6 @@ class OutputView( object ):
|
||||||
syntax,
|
syntax,
|
||||||
self._buffers[ category ].buf )
|
self._buffers[ category ].buf )
|
||||||
|
|
||||||
|
|
||||||
def _RenderWinBar( self, category ):
|
def _RenderWinBar( self, category ):
|
||||||
if not self._window.valid:
|
if not self._window.valid:
|
||||||
return
|
return
|
||||||
|
|
@ -216,6 +215,9 @@ class OutputView( object ):
|
||||||
def GetCategories( self ):
|
def GetCategories( self ):
|
||||||
return list( self._buffers.keys() )
|
return list( self._buffers.keys() )
|
||||||
|
|
||||||
|
def AddLogFileView( self, file_name = utils.LOG_FILE ):
|
||||||
|
self._CreateBuffer( 'Vimspector', file_name = file_name )
|
||||||
|
|
||||||
|
|
||||||
class DAPOutputView( OutputView ):
|
class DAPOutputView( OutputView ):
|
||||||
"""Specialised OutputView which adds the DAP Console (REPL)"""
|
"""Specialised OutputView which adds the DAP Console (REPL)"""
|
||||||
|
|
@ -226,7 +228,7 @@ class DAPOutputView( OutputView ):
|
||||||
for b in set( BUFFER_MAP.values() ):
|
for b in set( BUFFER_MAP.values() ):
|
||||||
self._CreateBuffer( b )
|
self._CreateBuffer( b )
|
||||||
|
|
||||||
self._CreateBuffer( 'Vimspector', file_name = utils.LOG_FILE )
|
self.AddLogFileView()
|
||||||
self._ShowOutput( 'Console' )
|
self._ShowOutput( 'Console' )
|
||||||
|
|
||||||
def ConnectionUp( self, connection ):
|
def ConnectionUp( self, connection ):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue