Merge pull request #208 from puremourning/eval-cursorpos

Put the cursor at the end of the buffer after evaluations
This commit is contained in:
mergify[bot] 2020-07-18 17:23:49 +00:00 committed by GitHub
commit db5073aec1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 13 deletions

View file

@ -126,20 +126,13 @@ class OutputView( object ):
self._ShowOutput( category )
def Evaluate( self, frame, expression ):
console = self._buffers[ 'Console' ].buf
with utils.ModifiableScratchBuffer( console ):
utils.AppendToBuffer( console, 'Evaluating: ' + expression )
self._Print( 'Console', [ 'Evaluating: ' + expression ] )
def print_result( message ):
with utils.ModifiableScratchBuffer( console ):
utils.AppendToBuffer( console,
'Evaluated: ' + expression )
result = message[ 'body' ][ 'result' ]
if result is None:
result = 'null'
utils.AppendToBuffer( console, ' Result: ' + result )
result = message[ 'body' ][ 'result' ]
if result is None:
result = '<no result>'
self._Print( 'Console', f' Result: { result }' )
request = {
'command': 'evaluate',

View file

@ -9,7 +9,9 @@ function! vimspector#test#signs#AssertCursorIsAtLineInBuffer( buffer,
call WaitForAssert( {->
\ assert_equal( a:line, line( '.' ), 'Current line' )
\ }, 10000 )
call assert_equal( a:column, col( '.' ), 'Current column' )
if a:column isnot v:null
call assert_equal( a:column, col( '.' ), 'Current column' )
endif
endfunction
function! vimspector#test#signs#AssertPCIsAtLineInBuffer( buffer, line ) abort

View file

@ -479,3 +479,46 @@ function! Test_ExpandWatch()
call vimspector#test#setup#Reset()
%bwipe!
endfunction
function Test_EvaluateConsole()
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 )
VimspectorEval t.i
call assert_equal( bufnr( 'vimspector.Console' ),
\ winbufnr( g:vimspector_session_windows.output ) )
call WaitForAssert( {->
\ assert_equal(
\ [
\ ' Result: 1'
\ ],
\ getbufline( bufnr( 'vimspector.Console' ), '$', '$' )
\ )
\ } )
let len = getbufinfo( 'vimspector.Console' )[ 0 ].linecount
call WaitForAssert( {->
\ assert_equal(
\ [
\ 'Evaluating: t.i',
\ ' Result: 1'
\ ],
\ getbufline( bufnr( 'vimspector.Console' ), len-1, '$' )
\ )
\ } )
call vimspector#test#signs#AssertCursorIsAtLineInBuffer(
\ 'vimspector.Console', len, v:null )
call vimspector#test#setup#Reset()
%bwipe!
endfunction