Add a splash popup while starting up
Sometimes it can take quite a while to start up and initialise the debug adapter. So we use popup/float to display the status as we start up and shut down. This increases minimum Vim version to 8.2, but that's been out for ages now and I intend to agressively require latest/later vim/neovim versions.
This commit is contained in:
parent
03d97dc58f
commit
1003cdc0b2
7 changed files with 173 additions and 6 deletions
|
|
@ -19,7 +19,6 @@ import logging
|
|||
import os
|
||||
import shlex
|
||||
import subprocess
|
||||
import traceback
|
||||
import functools
|
||||
import vim
|
||||
|
||||
|
|
@ -60,6 +59,7 @@ class DebugSession( object ):
|
|||
self._variablesView = None
|
||||
self._outputView = None
|
||||
self._breakpoints = breakpoints.ProjectBreakpoints()
|
||||
self._splash_screen = None
|
||||
|
||||
self._run_on_server_exit = None
|
||||
|
||||
|
|
@ -326,9 +326,12 @@ class DebugSession( object ):
|
|||
def _Reset( self ):
|
||||
self._logger.info( "Debugging complete." )
|
||||
if self._uiTab:
|
||||
self._logger.debug( "Clearing down UI with stack_trace: %s",
|
||||
traceback.format_stack() )
|
||||
self._logger.debug( "Clearing down UI" )
|
||||
vim.current.tabpage = self._uiTab
|
||||
|
||||
self._splash_screen = utils.HideSplash( self._api_prefix,
|
||||
self._splash_screen )
|
||||
|
||||
self._stackTraceView.Reset()
|
||||
self._variablesView.Reset()
|
||||
self._outputView.Reset()
|
||||
|
|
@ -436,6 +439,7 @@ class DebugSession( object ):
|
|||
def GetOutputBuffers( self ):
|
||||
return self._outputView.GetCategories()
|
||||
|
||||
@IfConnected
|
||||
def GetCompletionsSync( self, text_line, column_in_bytes ):
|
||||
if not self._server_capabilities.get( 'supportsCompletionsRequest' ):
|
||||
return []
|
||||
|
|
@ -523,6 +527,11 @@ class DebugSession( object ):
|
|||
return True
|
||||
|
||||
def _StartDebugAdapter( self ):
|
||||
self._splash_screen = utils.DisplaySplash(
|
||||
self._api_prefix,
|
||||
self._splash_screen,
|
||||
"Starting debug adapter..." )
|
||||
|
||||
if self._connection:
|
||||
utils.UserMessage( 'The connection is already created. Please try again',
|
||||
persist = True )
|
||||
|
|
@ -560,6 +569,9 @@ class DebugSession( object ):
|
|||
" g:_vimspector_adapter_spec "
|
||||
")".format( self._connection_type ) ):
|
||||
self._logger.error( "Unable to start debug server" )
|
||||
self._splash_screen = utils.DisplaySplash( self._api_prefix,
|
||||
self._splash_screen,
|
||||
"Unable to start adapter" )
|
||||
else:
|
||||
self._connection = debug_adapter_connection.DebugAdapterConnection(
|
||||
self,
|
||||
|
|
@ -570,6 +582,11 @@ class DebugSession( object ):
|
|||
self._logger.info( 'Debug Adapter Started' )
|
||||
|
||||
def _StopDebugAdapter( self, callback = None ):
|
||||
self._splash_screen = utils.DisplaySplash(
|
||||
self._api_prefix,
|
||||
self._splash_screen,
|
||||
"Shutting down debug adapter..." )
|
||||
|
||||
def handler( *args ):
|
||||
if callback:
|
||||
self._logger.debug( "Setting server exit handler before disconnect" )
|
||||
|
|
@ -706,6 +723,11 @@ class DebugSession( object ):
|
|||
return [ command ]
|
||||
|
||||
def _Initialise( self ):
|
||||
self._splash_screen = utils.DisplaySplash(
|
||||
self._api_prefix,
|
||||
self._splash_screen,
|
||||
"Initializing debug adapter..." )
|
||||
|
||||
# For a good explaination as to why this sequence is the way it is, see
|
||||
# https://github.com/microsoft/vscode/issues/4902#issuecomment-368583522
|
||||
#
|
||||
|
|
@ -760,8 +782,18 @@ class DebugSession( object ):
|
|||
launch_config.get( 'request', 'launch' ) )
|
||||
|
||||
if request == "attach":
|
||||
self._splash_screen = utils.DisplaySplash(
|
||||
self._api_prefix,
|
||||
self._splash_screen,
|
||||
"Attaching to debugee..." )
|
||||
|
||||
self._PrepareAttach( adapter_config, launch_config )
|
||||
elif request == "launch":
|
||||
self._splash_screen = utils.DisplaySplash(
|
||||
self._api_prefix,
|
||||
self._splash_screen,
|
||||
"Launching debugee..." )
|
||||
|
||||
# FIXME: This cmdLine hack is not fun.
|
||||
self._PrepareLaunch( self._configuration.get( 'remote-cmdLine', [] ),
|
||||
adapter_config,
|
||||
|
|
@ -807,6 +839,9 @@ class DebugSession( object ):
|
|||
# leader rather than the process. The workaround is to manually SIGTRAP the
|
||||
# PID.
|
||||
#
|
||||
self._splash_screen = utils.HideSplash( self._api_prefix,
|
||||
self._splash_screen )
|
||||
|
||||
if self._launch_complete and self._init_complete:
|
||||
for h in self._on_init_complete_handlers:
|
||||
h()
|
||||
|
|
|
|||
|
|
@ -546,3 +546,20 @@ def SetSyntax( current_syntax, syntax, *args ):
|
|||
def GetBufferFiletypes( buf ):
|
||||
ft = ToUnicode( vim.eval( f"getbufvar( {buf.number}, '&ft' )" ) )
|
||||
return ft.split( '.' )
|
||||
|
||||
|
||||
def DisplaySplash( api_prefix, splash, text ):
|
||||
if splash:
|
||||
return Call( f'vimspector#internal#{api_prefix}popup#UpdateSplash',
|
||||
splash,
|
||||
text )
|
||||
else:
|
||||
return Call( f'vimspector#internal#{api_prefix}popup#DisplaySplash',
|
||||
text )
|
||||
|
||||
|
||||
def HideSplash( api_prefix, splash ):
|
||||
if splash:
|
||||
Call( f'vimspector#internal#{api_prefix}popup#HideSplash', splash )
|
||||
|
||||
return None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue