Implement command line completion for watch/eval

This commit is contained in:
Ben Jackson 2020-01-17 00:02:24 +00:00
commit 355f0f0e0c
4 changed files with 53 additions and 3 deletions

View file

@ -65,6 +65,33 @@ class DebugAdapterConnection( object ):
if not self._SendMessage( msg ):
self._AbortRequest( request, 'Unable to send message' )
def DoRequestSync( self, msg, timeout = 5000 ):
result = {}
def handler( msg ):
result[ 'response' ] = msg
def failure_handler( reason, msg ):
result[ 'response' ] = msg
result[ 'exception' ] = RuntimeError( reason )
self.DoRequest( handler, msg, failure_handler, timeout )
bug_catcher = 1000
while not result and bug_catcher >= 0:
vim.command( 'sleep 10m' )
bug_catcher -= 10
if result.get( 'exception' ) is not None:
raise result[ 'exception' ]
if result.get( 'response' ) is None:
raise RuntimeError( "No response" )
return result[ 'response' ]
def OnRequestTimeout( self, timer_id ):
request_id = None
for seq, request in self._outstanding_requests.items():

View file

@ -406,6 +406,26 @@ class DebugSession( object ):
def GetOutputBuffers( self ):
return self._outputView.GetCategories()
def GetCompletionsSync( self, text_line, column_in_bytes ):
if not self._server_capabilities.get( 'supportsCompletionsRequest' ):
return []
response = self._connection.DoRequestSync( {
'command': 'completions',
'arguments': {
'frameId': self._stackTraceView.GetCurrentFrame()[ 'id' ],
# TODO: encoding ? bytes/codepoints
'text': text_line,
'column': column_in_bytes
}
} )
# TODO:
# - start / length
# - sortText
return [ i.get( 'text' ) or i[ 'label' ]
for i in response[ 'body' ][ 'targets' ] ]
def _SetUpUI( self ):
vim.command( 'tabnew' )
self._uiTab = vim.current.tabpage