Use popup for confirmations (note these have to be async)
This commit is contained in:
parent
afb912dd08
commit
63fd3165fb
5 changed files with 129 additions and 33 deletions
|
|
@ -29,12 +29,15 @@ class JavaDebugAdapter( object ):
|
|||
return
|
||||
|
||||
if body.get( 'changeType' ) == 'BUILD_COMPLETE':
|
||||
if utils.AskForInput( 'Code has changed, hot reload? [Y/N] ',
|
||||
'Y' ).upper()[ 0 ] == 'Y':
|
||||
self.debug_session._connection.DoRequest( None, {
|
||||
'command': 'redefineClasses',
|
||||
'arguments': {},
|
||||
} )
|
||||
def handler( result ):
|
||||
if result == 1:
|
||||
self.debug_session._connection.DoRequest( None, {
|
||||
'command': 'redefineClasses',
|
||||
'arguments': {},
|
||||
} )
|
||||
|
||||
utils.Confirm( self.debug_session._api_prefix,
|
||||
'Code has changed, hot reload?',
|
||||
handler )
|
||||
elif body.get( 'message' ):
|
||||
utils.UserMessage( 'Hot code replace: ' + body[ 'message' ] )
|
||||
|
||||
|
|
|
|||
|
|
@ -911,39 +911,52 @@ class DebugSession( object ):
|
|||
self._logger.info( 'Debug Adapter Started' )
|
||||
|
||||
def _StopDebugAdapter( self, interactive = False, callback = None ):
|
||||
self._splash_screen = utils.DisplaySplash(
|
||||
self._api_prefix,
|
||||
self._splash_screen,
|
||||
"Shutting down debug adapter..." )
|
||||
def disconnect( arguments = {} ):
|
||||
self._splash_screen = utils.DisplaySplash(
|
||||
self._api_prefix,
|
||||
self._splash_screen,
|
||||
"Shutting down debug adapter..." )
|
||||
|
||||
def handler( *args ):
|
||||
self._splash_screen = utils.HideSplash( self._api_prefix,
|
||||
self._splash_screen )
|
||||
def handler( *args ):
|
||||
self._splash_screen = utils.HideSplash( self._api_prefix,
|
||||
self._splash_screen )
|
||||
|
||||
if callback:
|
||||
self._logger.debug( "Setting server exit handler before disconnect" )
|
||||
assert not self._run_on_server_exit
|
||||
self._run_on_server_exit = callback
|
||||
if callback:
|
||||
self._logger.debug( "Setting server exit handler before disconnect" )
|
||||
assert not self._run_on_server_exit
|
||||
self._run_on_server_exit = callback
|
||||
|
||||
vim.eval( 'vimspector#internal#{}#StopDebugSession()'.format(
|
||||
self._connection_type ) )
|
||||
vim.eval( 'vimspector#internal#{}#StopDebugSession()'.format(
|
||||
self._connection_type ) )
|
||||
|
||||
arguments = {}
|
||||
if ( interactive and
|
||||
self._server_capabilities.get( 'supportTerminateDebuggee' ) ):
|
||||
if self._stackTraceView.AnyThreadsRunning():
|
||||
choice = utils.AskForInput( "Terminate debuggee [Y/N/default]? ", "" )
|
||||
if choice == "Y" or choice == "y":
|
||||
self._connection.DoRequest( handler, {
|
||||
'command': 'disconnect',
|
||||
'arguments': {},
|
||||
}, failure_handler = handler, timeout = 5000 )
|
||||
|
||||
if not interactive:
|
||||
disconnect()
|
||||
elif not self._server_capabilities.get( 'supportTerminateDebuggee' ):
|
||||
disconnect()
|
||||
elif not self._stackTraceView.AnyThreadsRunning():
|
||||
disconnect()
|
||||
else:
|
||||
def handle_choice( choice ):
|
||||
arguments = {}
|
||||
if choice == 1:
|
||||
arguments[ 'terminateDebuggee' ] = True
|
||||
elif choice == "N" or choice == 'n':
|
||||
elif choice == 0:
|
||||
arguments[ 'terminateDebuggee' ] = False
|
||||
elif choice == -1:
|
||||
# Abort
|
||||
return
|
||||
|
||||
self._connection.DoRequest( handler, {
|
||||
'command': 'disconnect',
|
||||
'arguments': arguments,
|
||||
}, failure_handler = handler, timeout = 5000 )
|
||||
disconnect( arguments )
|
||||
|
||||
# TODO: Use the 'tarminate' request if supportsTerminateRequest set
|
||||
utils.Confirm( self._api_prefix,
|
||||
"Terminate debuggee?",
|
||||
handle_choice,
|
||||
default_value = 3 )
|
||||
|
||||
|
||||
def _PrepareAttach( self, adapter_config, launch_config ):
|
||||
|
|
|
|||
|
|
@ -375,6 +375,31 @@ def AskForInput( prompt, default_value = None, completion = None ):
|
|||
return None
|
||||
|
||||
|
||||
CONFIRM = {}
|
||||
CONFIRM_ID = 0
|
||||
|
||||
def ConfirmCallback( confirm_id, result ):
|
||||
try:
|
||||
handler = CONFIRM.pop( confirm_id )
|
||||
except KeyError:
|
||||
UserMessage( f"Internal error: unexpected callback id { confirm_id }",
|
||||
persist = True,
|
||||
error = True )
|
||||
return
|
||||
|
||||
handler( result )
|
||||
|
||||
|
||||
def Confirm( api_prefix, prompt, handler, default_value = 1 ):
|
||||
global CONFIRM_ID
|
||||
CONFIRM_ID += 1
|
||||
CONFIRM[ CONFIRM_ID ] = handler
|
||||
Call( f'vimspector#internal#{ api_prefix }popup#Confirm',
|
||||
CONFIRM_ID,
|
||||
prompt,
|
||||
default_value )
|
||||
|
||||
|
||||
def AppendToBuffer( buf, line_or_lines, modified=False ):
|
||||
line = 1
|
||||
try:
|
||||
|
|
@ -403,8 +428,10 @@ def AppendToBuffer( buf, line_or_lines, modified=False ):
|
|||
|
||||
|
||||
|
||||
def ClearBuffer( buf ):
|
||||
def ClearBuffer( buf, modified = False ):
|
||||
buf[ : ] = None
|
||||
if not modified:
|
||||
buf.options[ 'modified' ] = False
|
||||
|
||||
|
||||
def SetBufferContents( buf, lines, modified=False ):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue