Minor improvements to console usage
Display failures and stop adding random text which makes the (very useful) CodeLLDB interface look messy
This commit is contained in:
parent
16f22b396f
commit
1b9763a4fc
4 changed files with 63 additions and 10 deletions
|
|
@ -183,7 +183,7 @@ function! vimspector#Evaluate( expr ) abort
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
py3 _vimspector_session.ShowOutput( 'Console' )
|
py3 _vimspector_session.ShowOutput( 'Console' )
|
||||||
py3 _vimspector_session.EvaluateConsole( vim.eval( 'a:expr' ) )
|
py3 _vimspector_session.EvaluateConsole( vim.eval( 'a:expr' ), True )
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! vimspector#EvaluateConsole( expr ) abort
|
function! vimspector#EvaluateConsole( expr ) abort
|
||||||
|
|
@ -192,7 +192,7 @@ function! vimspector#EvaluateConsole( expr ) abort
|
||||||
endif
|
endif
|
||||||
stopinsert
|
stopinsert
|
||||||
setlocal nomodified
|
setlocal nomodified
|
||||||
py3 _vimspector_session.EvaluateConsole( vim.eval( 'a:expr' ) )
|
py3 _vimspector_session.EvaluateConsole( vim.eval( 'a:expr' ), False )
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! vimspector#ShowOutput( ... ) abort
|
function! vimspector#ShowOutput( ... ) abort
|
||||||
|
|
|
||||||
|
|
@ -467,9 +467,10 @@ class DebugSession( object ):
|
||||||
expression )
|
expression )
|
||||||
|
|
||||||
@IfConnected()
|
@IfConnected()
|
||||||
def EvaluateConsole( self, expression ):
|
def EvaluateConsole( self, expression, verbose ):
|
||||||
self._outputView.Evaluate( self._stackTraceView.GetCurrentFrame(),
|
self._outputView.Evaluate( self._stackTraceView.GetCurrentFrame(),
|
||||||
expression )
|
expression,
|
||||||
|
verbose )
|
||||||
|
|
||||||
@IfConnected()
|
@IfConnected()
|
||||||
def DeleteWatch( self ):
|
def DeleteWatch( self ):
|
||||||
|
|
|
||||||
|
|
@ -260,14 +260,18 @@ class DAPOutputView( OutputView ):
|
||||||
# Don't clear because output is probably still useful
|
# Don't clear because output is probably still useful
|
||||||
self._connection = None
|
self._connection = None
|
||||||
|
|
||||||
def Evaluate( self, frame, expression ):
|
def Evaluate( self, frame, expression, verbose ):
|
||||||
self._Print( 'Console', [ 'Evaluating: ' + expression ] )
|
if verbose:
|
||||||
|
self._Print( 'Console', f"Evaluating: { expression }" )
|
||||||
|
|
||||||
def print_result( message ):
|
def print_result( message ):
|
||||||
result = message[ 'body' ][ 'result' ]
|
result = message[ 'body' ][ 'result' ]
|
||||||
if result is None:
|
if result is None:
|
||||||
result = '<no result>'
|
result = '<no result>'
|
||||||
self._Print( 'Console', f' Result: { result }' )
|
self._Print( 'Console', result.splitlines() )
|
||||||
|
|
||||||
|
def print_failure( reason, msg ):
|
||||||
|
self._Print( 'Console', reason.splitlines() )
|
||||||
|
|
||||||
request = {
|
request = {
|
||||||
'command': 'evaluate',
|
'command': 'evaluate',
|
||||||
|
|
@ -280,4 +284,6 @@ class DAPOutputView( OutputView ):
|
||||||
if frame:
|
if frame:
|
||||||
request[ 'arguments' ][ 'frameId' ] = frame[ 'id' ]
|
request[ 'arguments' ][ 'frameId' ] = frame[ 'id' ]
|
||||||
|
|
||||||
self._connection.DoRequest( print_result, request )
|
self._connection.DoRequest( print_result,
|
||||||
|
request,
|
||||||
|
print_failure )
|
||||||
|
|
|
||||||
|
|
@ -499,7 +499,7 @@ function Test_EvaluateConsole()
|
||||||
call WaitForAssert( {->
|
call WaitForAssert( {->
|
||||||
\ assert_equal(
|
\ assert_equal(
|
||||||
\ [
|
\ [
|
||||||
\ ' Result: 1'
|
\ '1'
|
||||||
\ ],
|
\ ],
|
||||||
\ getbufline( bufnr( 'vimspector.Console' ), '$', '$' )
|
\ getbufline( bufnr( 'vimspector.Console' ), '$', '$' )
|
||||||
\ )
|
\ )
|
||||||
|
|
@ -511,7 +511,7 @@ function Test_EvaluateConsole()
|
||||||
\ assert_equal(
|
\ assert_equal(
|
||||||
\ [
|
\ [
|
||||||
\ 'Evaluating: t.i',
|
\ 'Evaluating: t.i',
|
||||||
\ ' Result: 1'
|
\ '1'
|
||||||
\ ],
|
\ ],
|
||||||
\ getbufline( bufnr( 'vimspector.Console' ), len-1, '$' )
|
\ getbufline( bufnr( 'vimspector.Console' ), len-1, '$' )
|
||||||
\ )
|
\ )
|
||||||
|
|
@ -522,3 +522,49 @@ function Test_EvaluateConsole()
|
||||||
call vimspector#test#setup#Reset()
|
call vimspector#test#setup#Reset()
|
||||||
%bwipe!
|
%bwipe!
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function Test_EvaluatePromptConsole()
|
||||||
|
let fn = 'testdata/cpp/simple/struct.cpp'
|
||||||
|
call s:StartDebugging( #{ fn: fn, line: 24, col: 1, launch: #{
|
||||||
|
\ configuration: 'run-to-breakpoint'
|
||||||
|
\ } } )
|
||||||
|
|
||||||
|
" Make sure the Test t is initialised
|
||||||
|
call vimspector#StepOver()
|
||||||
|
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 26, 1 )
|
||||||
|
call vimspector#StepOver()
|
||||||
|
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 27, 1 )
|
||||||
|
|
||||||
|
VimspectorShowOutput
|
||||||
|
call assert_equal( bufnr( 'vimspector.Console' ),
|
||||||
|
\ winbufnr( g:vimspector_session_windows.output ) )
|
||||||
|
|
||||||
|
call feedkeys( "it.i\<CR>", 'xt' )
|
||||||
|
call WaitForAssert( {->
|
||||||
|
\ assert_equal(
|
||||||
|
\ [
|
||||||
|
\ '1'
|
||||||
|
\ ],
|
||||||
|
\ getbufline( bufnr( 'vimspector.Console' ), '$', '$' )
|
||||||
|
\ )
|
||||||
|
\ } )
|
||||||
|
|
||||||
|
let len = getbufinfo( 'vimspector.Console' )[ 0 ].linecount
|
||||||
|
|
||||||
|
call WaitForAssert( {->
|
||||||
|
\ assert_equal(
|
||||||
|
\ [
|
||||||
|
\ '> t.i',
|
||||||
|
\ '',
|
||||||
|
\ '1'
|
||||||
|
\ ],
|
||||||
|
\ getbufline( bufnr( 'vimspector.Console' ), len-2, '$' )
|
||||||
|
\ )
|
||||||
|
\ } )
|
||||||
|
call vimspector#test#signs#AssertCursorIsAtLineInBuffer(
|
||||||
|
\ 'vimspector.Console', len, v:null )
|
||||||
|
|
||||||
|
call vimspector#test#setup#Reset()
|
||||||
|
%bwipe!
|
||||||
|
endfunction
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue