fixing linting errors in python files
This commit is contained in:
parent
3c857cebf4
commit
e0b1d6ed81
3 changed files with 57 additions and 29 deletions
|
|
@ -521,7 +521,7 @@ class DebugSession( object ):
|
|||
|
||||
@IfConnected()
|
||||
def ExpandVariable( self, lineNum = -1 ):
|
||||
self._variablesView.ExpandVariable(lineNum)
|
||||
self._variablesView.ExpandVariable( lineNum )
|
||||
|
||||
@IfConnected()
|
||||
def AddWatch( self, expression ):
|
||||
|
|
@ -540,7 +540,7 @@ class DebugSession( object ):
|
|||
|
||||
|
||||
@IfConnected()
|
||||
def ShowTooltip(self, winnr, expression, is_hover):
|
||||
def ShowTooltip( self, winnr, expression, is_hover ):
|
||||
"""Proxy: ballonexpr -> variables.ShowBallon"""
|
||||
frame = self._stackTraceView.GetCurrentFrame()
|
||||
# Check if RIP is in a frame
|
||||
|
|
@ -556,9 +556,9 @@ class DebugSession( object ):
|
|||
return ''
|
||||
|
||||
# Return variable aware function
|
||||
return self._variablesView.VariableEval(frame, expression, is_hover)
|
||||
return self._variablesView.VariableEval( frame, expression, is_hover )
|
||||
|
||||
def _CleanUpTooltip(self):
|
||||
def _CleanUpTooltip( self ):
|
||||
return self._variablesView._CleanUpTooltip()
|
||||
|
||||
@IfConnected()
|
||||
|
|
|
|||
|
|
@ -640,9 +640,13 @@ def DisplayBaloon( is_term, display, is_hover = False ):
|
|||
# Refer https://github.com/vim/vim/issues/1512#issuecomment-492070685
|
||||
display = '\n'.join( display )
|
||||
|
||||
rc = int( vim.eval( "vimspector#internal#balloon#CreateTooltip({}, {})".format(is_hover, json.dumps( display )) ) )
|
||||
rc = int( vim.eval(
|
||||
"vimspector#internal#balloon#CreateTooltip({}, {})".format(
|
||||
is_hover, json.dumps( display )
|
||||
)
|
||||
) )
|
||||
|
||||
vim.eval("vimspector#internal#balloon#nvim_resize_tooltip()")
|
||||
vim.eval( "vimspector#internal#balloon#nvim_resize_tooltip()" )
|
||||
|
||||
return rc
|
||||
|
||||
|
|
|
|||
|
|
@ -122,10 +122,10 @@ class View:
|
|||
lines: typing.Dict[ int, Expandable ]
|
||||
draw: typing.Callable
|
||||
|
||||
def __init__( self, win, lines, draw):
|
||||
def __init__( self, win, lines, draw ):
|
||||
self.lines = lines
|
||||
self.draw = draw
|
||||
if (win is not None):
|
||||
if ( win is not None ):
|
||||
self.buf = win.buffer
|
||||
utils.SetUpUIWindow( win )
|
||||
|
||||
|
|
@ -138,8 +138,8 @@ class VariablesView( object ):
|
|||
self._connection = None
|
||||
self._current_syntax = ''
|
||||
|
||||
self._variable_eval = None
|
||||
self._variable_eval_view = None
|
||||
self._variable_eval: Scope = None
|
||||
self._variable_eval_view: View = None
|
||||
|
||||
def AddExpandMappings():
|
||||
vim.command( 'nnoremap <silent> <buffer> <CR> '
|
||||
|
|
@ -186,7 +186,9 @@ class VariablesView( object ):
|
|||
'balloonexpr': vim.options[ 'balloonexpr' ],
|
||||
'balloondelay': vim.options[ 'balloondelay' ],
|
||||
}
|
||||
vim.options[ 'balloonexpr' ] = 'vimspector#internal#balloon#HoverTooltip()'
|
||||
vim.options[ 'balloonexpr' ] = "vimspector#internal#"
|
||||
"balloon#HoverTooltip()"
|
||||
|
||||
vim.options[ 'balloondelay' ] = 250
|
||||
|
||||
if has_balloon:
|
||||
|
|
@ -270,28 +272,38 @@ class VariablesView( object ):
|
|||
},
|
||||
} )
|
||||
|
||||
def _DrawEval(self):
|
||||
def _DrawEval( self ):
|
||||
with utils.RestoreCursorPosition():
|
||||
with utils.ModifiableScratchBuffer( self._variable_eval_view.buf ):
|
||||
utils.ClearBuffer( self._variable_eval_view.buf )
|
||||
# if we only have a single non-expandable variable, it means we ran into a simple type
|
||||
# if we only have a single non-expandable variable,
|
||||
# it means we ran into a simple type
|
||||
# hence, there is no need to draw additional fluff around the value
|
||||
if(len(self._variable_eval.variables) == 1 and self._variable_eval.variables[0].IsExpandable() == False):
|
||||
if(
|
||||
len( self._variable_eval.variables ) == 1
|
||||
and self._variable_eval.variables[ 0 ].IsExpandable() is False
|
||||
):
|
||||
utils.AppendToBuffer(
|
||||
self._variable_eval_view.buf,
|
||||
self._variable_eval.variables[0].variable.get( 'value', '<unknown>' )
|
||||
)
|
||||
self._variable_eval.variables[ 0 ]
|
||||
.variable.get( 'value', '<unknown>' )
|
||||
)
|
||||
else:
|
||||
self._DrawVariables( self._variable_eval_view, self._variable_eval.variables, 2 , True)
|
||||
self._DrawVariables(
|
||||
self._variable_eval_view,
|
||||
self._variable_eval.variables,
|
||||
2,
|
||||
True
|
||||
)
|
||||
|
||||
vim.eval("vimspector#internal#balloon#nvim_resize_tooltip()")
|
||||
vim.eval( "vimspector#internal#balloon#nvim_resize_tooltip()" )
|
||||
|
||||
def _CleanUpTooltip(self):
|
||||
def _CleanUpTooltip( self ) :
|
||||
# remove reference to old tooltip window
|
||||
self._variable_eval_view = None
|
||||
return ''
|
||||
|
||||
def VariableEval(self, frame, expression, is_hover):
|
||||
def VariableEval( self, frame, expression, is_hover ):
|
||||
"""Callback to display variable under cursor `:h ballonexpr`"""
|
||||
if not self._connection:
|
||||
return ''
|
||||
|
|
@ -299,16 +311,24 @@ class VariablesView( object ):
|
|||
def handler( message ):
|
||||
body = message[ 'body' ]
|
||||
|
||||
self._variable_eval = Scope(body)
|
||||
float_win_id = utils.DisplayBaloon(self._is_term, [], is_hover)
|
||||
float_buf_nr = int(vim.eval("winbufnr({})".format(float_win_id)))
|
||||
self._variable_eval = Scope( body )
|
||||
float_win_id = utils.DisplayBaloon( self._is_term, [], is_hover )
|
||||
float_buf_nr = int( vim.eval( "winbufnr({})".format( float_win_id ) ) )
|
||||
|
||||
# since vim's popup cant be focused there is no way
|
||||
# to get a reference to its window
|
||||
# we will emulate python's window object ourselves
|
||||
self._variable_eval_view = View(type('__vim__window__', (object,), {'options': {}, 'buffer': vim.buffers[float_buf_nr]}), {}, self._DrawEval)
|
||||
self._variable_eval_view = View(
|
||||
type(
|
||||
'__vim__window__',
|
||||
( object, ),
|
||||
{ 'options': {}, 'buffer': vim.buffers[ float_buf_nr ] }
|
||||
),
|
||||
{},
|
||||
self._DrawEval
|
||||
)
|
||||
|
||||
if(self._variable_eval.VariablesReference() > 0):
|
||||
if( self._variable_eval.VariablesReference() > 0 ):
|
||||
self._connection.DoRequest( partial( self._ConsumeVariables,
|
||||
self._DrawEval,
|
||||
self._variable_eval ), {
|
||||
|
|
@ -318,9 +338,12 @@ class VariablesView( object ):
|
|||
},
|
||||
} )
|
||||
else:
|
||||
# in case that there is nothing to expand, we need to simulate a response from 'variables' request
|
||||
# in case that there is nothing to expand,
|
||||
# we need to simulate a response from 'variables' request
|
||||
# it returns [Variable]
|
||||
self._variable_eval.variables = [Variable({ 'type': body['type'], 'value': body['result']})]
|
||||
self._variable_eval.variables = [
|
||||
Variable( { 'type': body[ 'type' ], 'value': body[ 'result' ] } )
|
||||
]
|
||||
self._DrawEval()
|
||||
|
||||
|
||||
|
|
@ -422,7 +445,7 @@ class VariablesView( object ):
|
|||
else:
|
||||
return
|
||||
|
||||
current_line = vim.current.window.cursor[0] if lineNum <= 0 else lineNum
|
||||
current_line = vim.current.window.cursor[ 0 ] if lineNum <= 0 else lineNum
|
||||
if current_line not in view.lines:
|
||||
return
|
||||
|
||||
|
|
@ -474,7 +497,8 @@ class VariablesView( object ):
|
|||
|
||||
line = utils.AppendToBuffer(
|
||||
view.buf,
|
||||
text.split( '\n' ))
|
||||
text.split( '\n' )
|
||||
)
|
||||
|
||||
view.lines[ line ] = variable
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue