Allow closing of the UI windows; check valid flags and set buffers to be hidden. delete them on Reset
This commit is contained in:
parent
3643c2effd
commit
cb39e2b511
4 changed files with 34 additions and 28 deletions
|
|
@ -77,9 +77,10 @@ class OutputView( object ):
|
|||
self._ToggleFlag( category, True )
|
||||
|
||||
# Scroll the buffer
|
||||
with utils.RestoreCurrentWindow():
|
||||
with utils.RestoreCurrentBuffer( self._window ):
|
||||
self._ShowOutput( category )
|
||||
if self._window.valid:
|
||||
with utils.RestoreCurrentWindow():
|
||||
with utils.RestoreCurrentBuffer( self._window ):
|
||||
self._ShowOutput( category )
|
||||
|
||||
def ConnectionUp( self, connection ):
|
||||
self._connection = connection
|
||||
|
|
@ -96,18 +97,17 @@ class OutputView( object ):
|
|||
if tab_buffer.is_job:
|
||||
utils.CleanUpCommand( tab_buffer.job_category or category,
|
||||
self._api_prefix )
|
||||
try:
|
||||
vim.command( 'bdelete! {0}'.format( tab_buffer.buf.number ) )
|
||||
except vim.error as e:
|
||||
# FIXME: For now just ignore the "no buffers were deleted" error
|
||||
if 'E516' not in str( e ):
|
||||
raise
|
||||
utils.CleanUpHiddenBuffer( tab_buffer.buf )
|
||||
|
||||
# FIXME: nunmenu the WinBar ?
|
||||
self._buffers = {}
|
||||
|
||||
def _ShowOutput( self, category ):
|
||||
if not self._window.valid:
|
||||
return
|
||||
|
||||
utils.JumpToWindow( self._window )
|
||||
vim.command( 'bu {0}'.format( self._buffers[ category ].buf.name ) )
|
||||
vim.current.buffer = self._buffers[ category ].buf
|
||||
vim.command( 'normal G' )
|
||||
|
||||
def ShowOutput( self, category ):
|
||||
|
|
@ -146,8 +146,10 @@ class OutputView( object ):
|
|||
def _ToggleFlag( self, category, flag ):
|
||||
if self._buffers[ category ].flag != flag:
|
||||
self._buffers[ category ].flag = flag
|
||||
with utils.LetCurrentWindow( self._window ):
|
||||
self._RenderWinBar( category )
|
||||
|
||||
if self._window.valid:
|
||||
with utils.LetCurrentWindow( self._window ):
|
||||
self._RenderWinBar( category )
|
||||
|
||||
|
||||
def RunJobWithOutput( self, category, cmd ):
|
||||
|
|
@ -155,6 +157,9 @@ class OutputView( object ):
|
|||
|
||||
|
||||
def _CreateBuffer( self, category, file_name = None, cmd = None ):
|
||||
if not self._window.valid:
|
||||
return
|
||||
|
||||
with utils.LetCurrentWindow( self._window ):
|
||||
with utils.RestoreCurrentBuffer( self._window ):
|
||||
|
||||
|
|
@ -185,8 +190,7 @@ class OutputView( object ):
|
|||
utils.SetUpPromptBuffer( tab_buffer.buf,
|
||||
'vimspector.Console',
|
||||
'> ',
|
||||
'vimspector#EvaluateConsole',
|
||||
hidden=True )
|
||||
'vimspector#EvaluateConsole' )
|
||||
else:
|
||||
utils.SetUpHiddenBuffer(
|
||||
tab_buffer.buf,
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class StackTraceView( object ):
|
|||
|
||||
def Reset( self ):
|
||||
self.Clear()
|
||||
# TODO: delete the buffer ?
|
||||
utils.CleanUpHiddenBuffer( self._buf )
|
||||
|
||||
def LoadThreads( self, infer_current_frame ):
|
||||
pending_request = False
|
||||
|
|
|
|||
|
|
@ -86,15 +86,17 @@ def CleanUpCommand( name, api_prefix ):
|
|||
name ) )
|
||||
|
||||
|
||||
def CleanUpHiddenBuffer( buf ):
|
||||
try:
|
||||
vim.command( 'bdelete! {}'.format( buf.number ) )
|
||||
except vim.error as e:
|
||||
# FIXME: For now just ignore the "no buffers were deleted" error
|
||||
if 'E516' not in str( e ):
|
||||
raise
|
||||
|
||||
|
||||
def SetUpScratchBuffer( buf, name ):
|
||||
buf.options[ 'buftype' ] = 'nofile'
|
||||
buf.options[ 'swapfile' ] = False
|
||||
buf.options[ 'modifiable' ] = False
|
||||
buf.options[ 'modified' ] = False
|
||||
buf.options[ 'readonly' ] = True
|
||||
buf.options[ 'buflisted' ] = False
|
||||
buf.options[ 'bufhidden' ] = 'wipe'
|
||||
buf.name = name
|
||||
SetUpHiddenBuffer( buf, name )
|
||||
|
||||
|
||||
def SetUpHiddenBuffer( buf, name ):
|
||||
|
|
@ -108,7 +110,7 @@ def SetUpHiddenBuffer( buf, name ):
|
|||
buf.name = name
|
||||
|
||||
|
||||
def SetUpPromptBuffer( buf, name, prompt, callback, hidden=False ):
|
||||
def SetUpPromptBuffer( buf, name, prompt, callback ):
|
||||
# This feature is _super_ new, so only enable when available
|
||||
if not Exists( '*prompt_setprompt' ):
|
||||
return SetUpHiddenBuffer( buf, name )
|
||||
|
|
@ -119,7 +121,8 @@ def SetUpPromptBuffer( buf, name, prompt, callback, hidden=False ):
|
|||
buf.options[ 'modified' ] = False
|
||||
buf.options[ 'readonly' ] = False
|
||||
buf.options[ 'buflisted' ] = False
|
||||
buf.options[ 'bufhidden' ] = 'wipe' if not hidden else 'hide'
|
||||
buf.options[ 'bufhidden' ] = 'hide'
|
||||
buf.options[ 'textwidth' ] = 0
|
||||
buf.name = name
|
||||
|
||||
vim.eval( "prompt_setprompt( {0}, '{1}' )".format( buf.number,
|
||||
|
|
@ -177,7 +180,6 @@ def RestoreCurrentWindow():
|
|||
|
||||
@contextlib.contextmanager
|
||||
def RestoreCurrentBuffer( window ):
|
||||
# TODO: Don't trigger autoccommands when shifting buffers
|
||||
old_buffer = window.buffer
|
||||
try:
|
||||
yield
|
||||
|
|
|
|||
|
|
@ -200,8 +200,8 @@ class VariablesView( object ):
|
|||
for k, v in self._oldoptions.items():
|
||||
vim.options[ k ] = v
|
||||
|
||||
vim.command( 'bdelete! ' + str( self._watch.buf.number ) )
|
||||
vim.command( 'bdelete! ' + str( self._vars.buf.number ) )
|
||||
utils.CleanUpHiddenBuffer( self._vars.buf )
|
||||
utils.CleanUpHiddenBuffer( self._watch.buf )
|
||||
|
||||
def LoadScopes( self, frame ):
|
||||
def scopes_consumer( message ):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue