Merge pull request #39 from puremourning/fix-tabpage-errors
fix tabpage errors
This commit is contained in:
commit
be55649470
5 changed files with 97 additions and 29 deletions
|
|
@ -35,18 +35,17 @@ class CodeView( object ):
|
||||||
'breakpoints': []
|
'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( 'sign define vimspectorPC text=-> texthl=Search' )
|
||||||
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' )
|
|
||||||
|
|
||||||
|
|
||||||
def SetCurrentFrame( self, frame ):
|
def SetCurrentFrame( self, frame ):
|
||||||
|
|
@ -61,7 +60,7 @@ class CodeView( object ):
|
||||||
if 'path' not in frame[ 'source' ]:
|
if 'path' not in frame[ 'source' ]:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
vim.current.window = self._window
|
utils.JumpToWindow( self._window )
|
||||||
|
|
||||||
try:
|
try:
|
||||||
utils.OpenFileInCurrentWindow( frame[ 'source' ][ 'path' ] )
|
utils.OpenFileInCurrentWindow( frame[ 'source' ][ 'path' ] )
|
||||||
|
|
@ -210,8 +209,7 @@ class CodeView( object ):
|
||||||
buffer_number = None
|
buffer_number = None
|
||||||
with utils.TemporaryVimOptions( { 'splitright': True,
|
with utils.TemporaryVimOptions( { 'splitright': True,
|
||||||
'equalalways': False } ):
|
'equalalways': False } ):
|
||||||
with utils.RestoreCurrentWindow():
|
with utils.LetCurrentWindow( self._window ):
|
||||||
vim.current.window = self._window
|
|
||||||
# TODO/FIXME: Do something about closing this when we reset ?
|
# TODO/FIXME: Do something about closing this when we reset ?
|
||||||
vim_cmd = 'term_start( {}, {} )'.format( json.dumps( args ),
|
vim_cmd = 'term_start( {}, {} )'.format( json.dumps( args ),
|
||||||
json.dumps( options ) )
|
json.dumps( options ) )
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ class OutputView( object ):
|
||||||
self._buffers.clear()
|
self._buffers.clear()
|
||||||
|
|
||||||
def _ShowOutput( self, category ):
|
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( 'bu {0}'.format( self._buffers[ category ].buf.name ) )
|
||||||
vim.command( 'normal G' )
|
vim.command( 'normal G' )
|
||||||
|
|
||||||
|
|
@ -144,8 +144,7 @@ class OutputView( object ):
|
||||||
def _ToggleFlag( self, category, flag ):
|
def _ToggleFlag( self, category, flag ):
|
||||||
if self._buffers[ category ].flag != flag:
|
if self._buffers[ category ].flag != flag:
|
||||||
self._buffers[ category ].flag = flag
|
self._buffers[ category ].flag = flag
|
||||||
with utils.RestoreCurrentWindow():
|
with utils.LetCurrentWindow( self._window ):
|
||||||
vim.current.window = self._window
|
|
||||||
self._RenderWinBar( category )
|
self._RenderWinBar( category )
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -154,9 +153,7 @@ class OutputView( object ):
|
||||||
|
|
||||||
|
|
||||||
def _CreateBuffer( self, category, file_name = None, cmd = None ):
|
def _CreateBuffer( self, category, file_name = None, cmd = None ):
|
||||||
with utils.RestoreCurrentWindow():
|
with utils.LetCurrentWindow( self._window ):
|
||||||
vim.current.window = self._window
|
|
||||||
|
|
||||||
with utils.RestoreCurrentBuffer( self._window ):
|
with utils.RestoreCurrentBuffer( self._window ):
|
||||||
|
|
||||||
if file_name is not None:
|
if file_name is not None:
|
||||||
|
|
|
||||||
|
|
@ -147,11 +147,13 @@ def RestoreCursorPosition():
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def RestoreCurrentWindow():
|
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
|
old_window = vim.current.window
|
||||||
try:
|
try:
|
||||||
yield
|
yield
|
||||||
finally:
|
finally:
|
||||||
|
vim.current.tabpage = old_tabpage
|
||||||
vim.current.window = old_window
|
vim.current.window = old_window
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -167,6 +169,18 @@ def RestoreCurrentBuffer( window ):
|
||||||
vim.current.buffer = old_buffer
|
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
|
@contextlib.contextmanager
|
||||||
def TemporaryVimOptions( opts ):
|
def TemporaryVimOptions( opts ):
|
||||||
old_value = {}
|
old_value = {}
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,9 @@ class VariablesView( object ):
|
||||||
self._connection = connection
|
self._connection = connection
|
||||||
|
|
||||||
# Allows us to hit <CR> to expand/collapse variables
|
# Allows us to hit <CR> to expand/collapse variables
|
||||||
vim.current.window = self._vars.win
|
with utils.LetCurrentWindow( self._vars.win ):
|
||||||
vim.command(
|
vim.command(
|
||||||
'nnoremap <buffer> <CR> :call vimspector#ExpandVariable()<CR>' )
|
'nnoremap <buffer> <CR> :call vimspector#ExpandVariable()<CR>' )
|
||||||
|
|
||||||
# This is actually the tree (scopes are alwyas the root)
|
# This is actually the tree (scopes are alwyas the root)
|
||||||
# it's just a list of DAP scope dicts, with one magic key (_variables)
|
# it's just a list of DAP scope dicts, with one magic key (_variables)
|
||||||
|
|
@ -52,11 +52,11 @@ class VariablesView( object ):
|
||||||
self._watches = []
|
self._watches = []
|
||||||
|
|
||||||
# Allows us to hit <CR> to expand/collapse variables
|
# Allows us to hit <CR> to expand/collapse variables
|
||||||
vim.current.window = self._watch.win
|
with utils.LetCurrentWindow( self._watch.win ):
|
||||||
vim.command(
|
vim.command(
|
||||||
'nnoremap <buffer> <CR> :call vimspector#ExpandVariable()<CR>' )
|
'nnoremap <buffer> <CR> :call vimspector#ExpandVariable()<CR>' )
|
||||||
vim.command(
|
vim.command(
|
||||||
'nnoremap <buffer> <DEL> :call vimspector#DeleteWatch()<CR>' )
|
'nnoremap <buffer> <DEL> :call vimspector#DeleteWatch()<CR>' )
|
||||||
|
|
||||||
utils.SetUpScratchBuffer( self._vars.win.buffer, 'vimspector.Variables' )
|
utils.SetUpScratchBuffer( self._vars.win.buffer, 'vimspector.Variables' )
|
||||||
utils.SetUpPromptBuffer( self._watch.win.buffer,
|
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