fix tabpage errors
This commit is contained in:
parent
1473e9d23b
commit
cee10c8187
5 changed files with 97 additions and 29 deletions
|
|
@ -35,18 +35,17 @@ class CodeView( object ):
|
|||
'breakpoints': []
|
||||
}
|
||||
|
||||
vim.current.window = self._window
|
||||
with utils.LetCurrentWindow( self._window ):
|
||||
vim.command( 'nnoremenu WinBar.Continue :call vimspector#Continue()<CR>' )
|
||||
vim.command( 'nnoremenu WinBar.Next :call vimspector#StepOver()<CR>' )
|
||||
vim.command( 'nnoremenu WinBar.Step :call vimspector#StepInto()<CR>' )
|
||||
vim.command( 'nnoremenu WinBar.Finish :call vimspector#StepOut()<CR>' )
|
||||
vim.command( 'nnoremenu WinBar.Pause :call vimspector#Pause()<CR>' )
|
||||
vim.command( 'nnoremenu WinBar.Stop :call vimspector#Stop()<CR>' )
|
||||
vim.command( 'nnoremenu WinBar.Restart :call vimspector#Restart()<CR>' )
|
||||
vim.command( 'nnoremenu WinBar.Reset :call vimspector#Reset()<CR>' )
|
||||
|
||||
vim.command( 'nnoremenu WinBar.Continue :call vimspector#Continue()<CR>' )
|
||||
vim.command( 'nnoremenu WinBar.Next :call vimspector#StepOver()<CR>' )
|
||||
vim.command( 'nnoremenu WinBar.Step :call vimspector#StepInto()<CR>' )
|
||||
vim.command( 'nnoremenu WinBar.Finish :call vimspector#StepOut()<CR>' )
|
||||
vim.command( 'nnoremenu WinBar.Pause :call vimspector#Pause()<CR>' )
|
||||
vim.command( 'nnoremenu WinBar.Stop :call vimspector#Stop()<CR>' )
|
||||
vim.command( 'nnoremenu WinBar.Restart :call vimspector#Restart()<CR>' )
|
||||
vim.command( 'nnoremenu WinBar.Reset :call vimspector#Reset()<CR>' )
|
||||
|
||||
vim.command( 'sign define vimspectorPC text=-> texthl=Search' )
|
||||
vim.command( 'sign define vimspectorPC text=-> texthl=Search' )
|
||||
|
||||
|
||||
def SetCurrentFrame( self, frame ):
|
||||
|
|
@ -61,7 +60,7 @@ class CodeView( object ):
|
|||
if 'path' not in frame[ 'source' ]:
|
||||
return False
|
||||
|
||||
vim.current.window = self._window
|
||||
utils.JumpToWindow( self._window )
|
||||
|
||||
try:
|
||||
utils.OpenFileInCurrentWindow( frame[ 'source' ][ 'path' ] )
|
||||
|
|
@ -210,8 +209,7 @@ class CodeView( object ):
|
|||
buffer_number = None
|
||||
with utils.TemporaryVimOptions( { 'splitright': True,
|
||||
'equalalways': False } ):
|
||||
with utils.RestoreCurrentWindow():
|
||||
vim.current.window = self._window
|
||||
with utils.LetCurrentWindow( self._window ):
|
||||
# TODO/FIXME: Do something about closing this when we reset ?
|
||||
vim_cmd = 'term_start( {}, {} )'.format( json.dumps( args ),
|
||||
json.dumps( options ) )
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ class OutputView( object ):
|
|||
self._buffers.clear()
|
||||
|
||||
def _ShowOutput( self, category ):
|
||||
vim.current.window = self._window
|
||||
utils.JumpToWindow( self._window )
|
||||
vim.command( 'bu {0}'.format( self._buffers[ category ].buf.name ) )
|
||||
vim.command( 'normal G' )
|
||||
|
||||
|
|
@ -144,8 +144,7 @@ class OutputView( object ):
|
|||
def _ToggleFlag( self, category, flag ):
|
||||
if self._buffers[ category ].flag != flag:
|
||||
self._buffers[ category ].flag = flag
|
||||
with utils.RestoreCurrentWindow():
|
||||
vim.current.window = self._window
|
||||
with utils.LetCurrentWindow( self._window ):
|
||||
self._RenderWinBar( category )
|
||||
|
||||
|
||||
|
|
@ -154,9 +153,7 @@ class OutputView( object ):
|
|||
|
||||
|
||||
def _CreateBuffer( self, category, file_name = None, cmd = None ):
|
||||
with utils.RestoreCurrentWindow():
|
||||
vim.current.window = self._window
|
||||
|
||||
with utils.LetCurrentWindow( self._window ):
|
||||
with utils.RestoreCurrentBuffer( self._window ):
|
||||
|
||||
if file_name is not None:
|
||||
|
|
|
|||
|
|
@ -147,11 +147,13 @@ def RestoreCursorPosition():
|
|||
|
||||
@contextlib.contextmanager
|
||||
def RestoreCurrentWindow():
|
||||
# TODO: Don't trigger autoccommands when shifting windows
|
||||
# TODO: Don't trigger autocommands when shifting windows
|
||||
old_tabpage = vim.current.tabpage
|
||||
old_window = vim.current.window
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
vim.current.tabpage = old_tabpage
|
||||
vim.current.window = old_window
|
||||
|
||||
|
||||
|
|
@ -167,6 +169,18 @@ def RestoreCurrentBuffer( window ):
|
|||
vim.current.buffer = old_buffer
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def LetCurrentWindow( window ):
|
||||
with RestoreCurrentWindow():
|
||||
JumpToWindow( window )
|
||||
yield
|
||||
|
||||
|
||||
def JumpToWindow( window ):
|
||||
vim.current.tabpage = window.tabpage
|
||||
vim.current.window = window
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def TemporaryVimOptions( opts ):
|
||||
old_value = {}
|
||||
|
|
|
|||
|
|
@ -33,9 +33,9 @@ class VariablesView( object ):
|
|||
self._connection = connection
|
||||
|
||||
# Allows us to hit <CR> to expand/collapse variables
|
||||
vim.current.window = self._vars.win
|
||||
vim.command(
|
||||
'nnoremap <buffer> <CR> :call vimspector#ExpandVariable()<CR>' )
|
||||
with utils.LetCurrentWindow( self._vars.win ):
|
||||
vim.command(
|
||||
'nnoremap <buffer> <CR> :call vimspector#ExpandVariable()<CR>' )
|
||||
|
||||
# This is actually the tree (scopes are alwyas the root)
|
||||
# it's just a list of DAP scope dicts, with one magic key (_variables)
|
||||
|
|
@ -52,11 +52,11 @@ class VariablesView( object ):
|
|||
self._watches = []
|
||||
|
||||
# Allows us to hit <CR> to expand/collapse variables
|
||||
vim.current.window = self._watch.win
|
||||
vim.command(
|
||||
'nnoremap <buffer> <CR> :call vimspector#ExpandVariable()<CR>' )
|
||||
vim.command(
|
||||
'nnoremap <buffer> <DEL> :call vimspector#DeleteWatch()<CR>' )
|
||||
with utils.LetCurrentWindow( self._watch.win ):
|
||||
vim.command(
|
||||
'nnoremap <buffer> <CR> :call vimspector#ExpandVariable()<CR>' )
|
||||
vim.command(
|
||||
'nnoremap <buffer> <DEL> :call vimspector#DeleteWatch()<CR>' )
|
||||
|
||||
utils.SetUpScratchBuffer( self._vars.win.buffer, 'vimspector.Variables' )
|
||||
utils.SetUpPromptBuffer( self._watch.win.buffer,
|
||||
|
|
|
|||
59
tests/tabpage.test.vim
Normal file
59
tests/tabpage.test.vim
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
source lib/shared.vim
|
||||
|
||||
function! SetUp()
|
||||
if exists ( 'g:loaded_vimpector' )
|
||||
unlet g:loaded_vimpector
|
||||
endif
|
||||
|
||||
let g:vimspector_enable_mappings = 'HUMAN'
|
||||
source vimrc
|
||||
|
||||
" This is a bit of a hack
|
||||
runtime! plugin/**/*.vim
|
||||
endfunction
|
||||
|
||||
function! Test_Step_With_Different_Tabpage()
|
||||
lcd testdata/cpp/simple
|
||||
edit simple.cpp
|
||||
|
||||
" Add the breakpoing
|
||||
" TODO refactor FeedKeys
|
||||
15
|
||||
call assert_equal( 15, line( '.' ) )
|
||||
call feedkeys( "\<F9>", 'xt' )
|
||||
|
||||
" Here we go. Start Debugging
|
||||
call feedkeys( "\<F5>", 'xt' )
|
||||
|
||||
call assert_equal( 2, len( gettabinfo() ) )
|
||||
let vimspector_tabnr = tabpagenr()
|
||||
call WaitForAssert( {->
|
||||
\ assert_equal( 'simple.cpp', bufname( '%' ), 'Current buffer' )
|
||||
\ }, 10000 )
|
||||
call assert_equal( 15, line( '.' ), 'Current line' )
|
||||
call assert_equal( 1, col( '.' ), 'Current column' )
|
||||
|
||||
" Switch to the other tab
|
||||
normal gt
|
||||
|
||||
call assert_notequal( vimspector_tabnr, tabpagenr() )
|
||||
|
||||
" trigger some output by hacking into the vimspector python
|
||||
call py3eval( '_vimspector_session._outputView.Print( "server",'
|
||||
\ . ' "This is a test" )' )
|
||||
|
||||
" Step - jumps back to our vimspector tab
|
||||
call feedkeys( "\<F10>", 'xt' )
|
||||
|
||||
call WaitForAssert( {-> assert_equal( vimspector_tabnr, tabpagenr() ) } )
|
||||
call WaitForAssert( {-> assert_equal( 16, line( '.' ), 'Current line' ) } )
|
||||
call assert_equal( 'simple.cpp', bufname( '%' ), 'Current buffer' )
|
||||
call assert_equal( 1, col( '.' ), 'Current column' )
|
||||
|
||||
call vimspector#Reset()
|
||||
call vimspector#ClearBreakpoints()
|
||||
|
||||
lcd -
|
||||
%bwipeout!
|
||||
endfunction
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue