Start to add a test, but it's hitting deleting buffer that's in use [NULL]...

This commit is contained in:
Ben Jackson 2021-04-04 15:08:05 +01:00
commit e7fb49f03d
5 changed files with 71 additions and 17 deletions

View file

@ -47,6 +47,16 @@ function! vimspector#internal#state#GetAPIPrefix() abort
return s:prefix
endfunction
function! vimspector#internal#state#TabClosed() abort
py3 << EOF
if ( '_vimspector_session' in globals() and _vimspector_session
and not _vimspector_session._HasUI() ):
_vimspector_session.Reset( interactive = False )
EOF
endfunction
" Boilerplate {{{
let &cpoptions=s:save_cpo
unlet s:save_cpo

View file

@ -155,7 +155,9 @@ if ! has( 'gui_running' )
" å is the right-option+q
nnoremap <buffer> å :cfirst<CR>
" å is the right-option+a
nnoremap <buffer> œ :FuncLine<CR>
nnoremap <buffer> œ :cnext<CR>
" å is the right-option+f
nnoremap <buffer> ƒ :FuncLine<CR>
" Ω is the right-option+z
nnoremap <buffer> Ω :cprevious<CR>
endif

View file

@ -145,9 +145,14 @@ augroup VimspectorUserAutoCmds
augroup END
" FIXME: Only register this _while_ debugging is active
let g:vimspector_resetting = 0
augroup Vimspector
autocmd!
autocmd BufNew * call vimspector#OnBufferCreated( expand( '<afile>' ) )
autocmd TabClosed *
\ if !g:vimspector_resetting
\ | call vimspector#internal#state#TabClosed()
\ | endif
augroup END
" boilerplate {{{

View file

@ -61,6 +61,7 @@ class DebugSession( object ):
self._stackTraceView = None
self._variablesView = None
self._outputView = None
self._codeView = None
self._breakpoints = breakpoints.ProjectBreakpoints()
self._splash_screen = None
self._remote_term = None
@ -404,27 +405,43 @@ class DebugSession( object ):
self._Reset()
def _Reset( self ):
vim.vars[ 'vimspector_resetting' ] = 1
self._logger.info( "Debugging complete." )
def ResetUI():
if self._stackTraceView:
self._stackTraceView.Reset()
if self._variablesView:
self._variablesView.Reset()
if self._outputView:
self._outputView.Reset()
if self._codeView:
self._codeView.Reset()
self._stackTraceView = None
self._variablesView = None
self._outputView = None
self._codeView = None
self._remote_term = None
self._uiTab = None
if self._HasUI():
self._logger.debug( "Clearing down UI" )
vim.current.tabpage = self._uiTab
self._splash_screen = utils.HideSplash( self._api_prefix,
self._splash_screen )
self._stackTraceView.Reset()
self._variablesView.Reset()
self._outputView.Reset()
self._codeView.Reset()
vim.command( 'au! VimspectorReset TabClose <buffer>' )
ResetUI()
vim.command( 'tabclose!' )
else:
ResetUI()
try:
del vim.vars[ 'vimspector_session_windows' ]
except KeyError:
pass
del vim.vars[ 'vimspector_session_windows' ]
vim.command( 'doautocmd <nomodeline> User VimspectorDebugEnded' )
self._stackTraceView = None
self._variablesView = None
self._outputView = None
self._codeView = None
self._remote_term = None
self._uiTab = None
vim.vars[ 'vimspector_resetting' ] = 0
# make sure that we're displaying signs in any still-open buffers
self._breakpoints.UpdateUI()
@ -667,10 +684,6 @@ class DebugSession( object ):
def _SetUpUI( self ):
vim.command( 'tab split' )
self._uiTab = vim.current.tabpage
vim.command( 'augroup VimspectorReset' )
vim.command( 'au TabClosed <buffer> call vimspector#Reset()' )
vim.command( 'augroup END' )
mode = settings.Get( 'ui_mode' )

View file

@ -6,6 +6,17 @@ function! ClearDown()
call vimspector#test#setup#ClearDown()
endfunction
let s:fn='../support/test/python/simple_python/main.py'
function! s:StartDebugging()
exe 'edit ' . s:fn
call setpos( '.', [ 0, 23, 1 ] )
call vimspector#ToggleBreakpoint()
call vimspector#LaunchWithSettings( { 'configuration': 'run' } )
call vimspector#test#signs#AssertCursorIsAtLineInBuffer( s:fn, 23, 1 )
endfunction
function! Test_Step_With_Different_Tabpage()
lcd testdata/cpp/simple
edit simple.cpp
@ -154,3 +165,16 @@ function! Test_All_Buffers_Deleted_Installer()
au! Test_All_Buffers_Deleted_Installer
%bwipe!
endfunction
function! Test_Close_Tab_No_Vimspector()
tabnew
q
%bwipe!
endfunction
function! Test_Close_Tab_With_Vimspector()
call s:StartDebugging()
tabclose!
call vimspector#test#setup#WaitForReset()
%bwipe!
endfunction