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 )
|
self._ToggleFlag( category, True )
|
||||||
|
|
||||||
# Scroll the buffer
|
# Scroll the buffer
|
||||||
with utils.RestoreCurrentWindow():
|
if self._window.valid:
|
||||||
with utils.RestoreCurrentBuffer( self._window ):
|
with utils.RestoreCurrentWindow():
|
||||||
self._ShowOutput( category )
|
with utils.RestoreCurrentBuffer( self._window ):
|
||||||
|
self._ShowOutput( category )
|
||||||
|
|
||||||
def ConnectionUp( self, connection ):
|
def ConnectionUp( self, connection ):
|
||||||
self._connection = connection
|
self._connection = connection
|
||||||
|
|
@ -96,18 +97,17 @@ class OutputView( object ):
|
||||||
if tab_buffer.is_job:
|
if tab_buffer.is_job:
|
||||||
utils.CleanUpCommand( tab_buffer.job_category or category,
|
utils.CleanUpCommand( tab_buffer.job_category or category,
|
||||||
self._api_prefix )
|
self._api_prefix )
|
||||||
try:
|
utils.CleanUpHiddenBuffer( tab_buffer.buf )
|
||||||
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
|
|
||||||
|
|
||||||
|
# FIXME: nunmenu the WinBar ?
|
||||||
self._buffers = {}
|
self._buffers = {}
|
||||||
|
|
||||||
def _ShowOutput( self, category ):
|
def _ShowOutput( self, category ):
|
||||||
|
if not self._window.valid:
|
||||||
|
return
|
||||||
|
|
||||||
utils.JumpToWindow( self._window )
|
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' )
|
vim.command( 'normal G' )
|
||||||
|
|
||||||
def ShowOutput( self, category ):
|
def ShowOutput( self, category ):
|
||||||
|
|
@ -146,8 +146,10 @@ 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.LetCurrentWindow( self._window ):
|
|
||||||
self._RenderWinBar( category )
|
if self._window.valid:
|
||||||
|
with utils.LetCurrentWindow( self._window ):
|
||||||
|
self._RenderWinBar( category )
|
||||||
|
|
||||||
|
|
||||||
def RunJobWithOutput( self, category, cmd ):
|
def RunJobWithOutput( self, category, cmd ):
|
||||||
|
|
@ -155,6 +157,9 @@ class OutputView( object ):
|
||||||
|
|
||||||
|
|
||||||
def _CreateBuffer( self, category, file_name = None, cmd = None ):
|
def _CreateBuffer( self, category, file_name = None, cmd = None ):
|
||||||
|
if not self._window.valid:
|
||||||
|
return
|
||||||
|
|
||||||
with utils.LetCurrentWindow( self._window ):
|
with utils.LetCurrentWindow( self._window ):
|
||||||
with utils.RestoreCurrentBuffer( self._window ):
|
with utils.RestoreCurrentBuffer( self._window ):
|
||||||
|
|
||||||
|
|
@ -185,8 +190,7 @@ class OutputView( object ):
|
||||||
utils.SetUpPromptBuffer( tab_buffer.buf,
|
utils.SetUpPromptBuffer( tab_buffer.buf,
|
||||||
'vimspector.Console',
|
'vimspector.Console',
|
||||||
'> ',
|
'> ',
|
||||||
'vimspector#EvaluateConsole',
|
'vimspector#EvaluateConsole' )
|
||||||
hidden=True )
|
|
||||||
else:
|
else:
|
||||||
utils.SetUpHiddenBuffer(
|
utils.SetUpHiddenBuffer(
|
||||||
tab_buffer.buf,
|
tab_buffer.buf,
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ class StackTraceView( object ):
|
||||||
|
|
||||||
def Reset( self ):
|
def Reset( self ):
|
||||||
self.Clear()
|
self.Clear()
|
||||||
# TODO: delete the buffer ?
|
utils.CleanUpHiddenBuffer( self._buf )
|
||||||
|
|
||||||
def LoadThreads( self, infer_current_frame ):
|
def LoadThreads( self, infer_current_frame ):
|
||||||
pending_request = False
|
pending_request = False
|
||||||
|
|
|
||||||
|
|
@ -86,15 +86,17 @@ def CleanUpCommand( name, api_prefix ):
|
||||||
name ) )
|
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 ):
|
def SetUpScratchBuffer( buf, name ):
|
||||||
buf.options[ 'buftype' ] = 'nofile'
|
SetUpHiddenBuffer( buf, name )
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
def SetUpHiddenBuffer( buf, name ):
|
def SetUpHiddenBuffer( buf, name ):
|
||||||
|
|
@ -108,7 +110,7 @@ def SetUpHiddenBuffer( buf, name ):
|
||||||
buf.name = 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
|
# This feature is _super_ new, so only enable when available
|
||||||
if not Exists( '*prompt_setprompt' ):
|
if not Exists( '*prompt_setprompt' ):
|
||||||
return SetUpHiddenBuffer( buf, name )
|
return SetUpHiddenBuffer( buf, name )
|
||||||
|
|
@ -119,7 +121,8 @@ def SetUpPromptBuffer( buf, name, prompt, callback, hidden=False ):
|
||||||
buf.options[ 'modified' ] = False
|
buf.options[ 'modified' ] = False
|
||||||
buf.options[ 'readonly' ] = False
|
buf.options[ 'readonly' ] = False
|
||||||
buf.options[ 'buflisted' ] = 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
|
buf.name = name
|
||||||
|
|
||||||
vim.eval( "prompt_setprompt( {0}, '{1}' )".format( buf.number,
|
vim.eval( "prompt_setprompt( {0}, '{1}' )".format( buf.number,
|
||||||
|
|
@ -177,7 +180,6 @@ def RestoreCurrentWindow():
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def RestoreCurrentBuffer( window ):
|
def RestoreCurrentBuffer( window ):
|
||||||
# TODO: Don't trigger autoccommands when shifting buffers
|
|
||||||
old_buffer = window.buffer
|
old_buffer = window.buffer
|
||||||
try:
|
try:
|
||||||
yield
|
yield
|
||||||
|
|
|
||||||
|
|
@ -200,8 +200,8 @@ class VariablesView( object ):
|
||||||
for k, v in self._oldoptions.items():
|
for k, v in self._oldoptions.items():
|
||||||
vim.options[ k ] = v
|
vim.options[ k ] = v
|
||||||
|
|
||||||
vim.command( 'bdelete! ' + str( self._watch.buf.number ) )
|
utils.CleanUpHiddenBuffer( self._vars.buf )
|
||||||
vim.command( 'bdelete! ' + str( self._vars.buf.number ) )
|
utils.CleanUpHiddenBuffer( self._watch.buf )
|
||||||
|
|
||||||
def LoadScopes( self, frame ):
|
def LoadScopes( self, frame ):
|
||||||
def scopes_consumer( message ):
|
def scopes_consumer( message ):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue