making sure to open popup relative to cursor

This commit is contained in:
dsych 2020-12-13 22:25:27 -05:00 committed by Ben Jackson
commit d2990d7bae
5 changed files with 29 additions and 31 deletions

View file

@ -540,7 +540,7 @@ class DebugSession( object ):
@IfConnected()
def ShowTooltip(self, winnr, expression):
def ShowTooltip(self, winnr, expression, is_hover):
"""Proxy: ballonexpr -> variables.ShowBallon"""
frame = self._stackTraceView.GetCurrentFrame()
# Check if RIP is in a frame
@ -556,7 +556,7 @@ class DebugSession( object ):
return ''
# Return variable aware function
return self._variablesView.VariableEval(frame, expression)
return self._variablesView.VariableEval(frame, expression, is_hover)
def _CleanUpTooltip(self):
return self._variablesView._CleanUpTooltip()

View file

@ -634,19 +634,13 @@ def ParseVariables( variables_list,
return new_variables
def DisplayBaloon( is_term, display ):
if int(vim.eval("has('nvim')")):
vim.eval("vimspector#internal#state#TooltipExec({})".format(display))
return
def DisplayBaloon( is_term, display, is_hover = False ):
if not is_term:
display = '\n'.join( display )
# To enable the Windows GUI to display the balloon correctly
# Refer https://github.com/vim/vim/issues/1512#issuecomment-492070685
vim.eval( "balloon_show( '' )" )
display = '\n'.join( display )
vim.eval( "balloon_show( {0} )".format(
json.dumps( display ) ) )
return int( vim.eval( "vimspector#internal#balloon#CreateTooltip({}, {})".format(is_hover, json.dumps( display )) ) )
def GetBufferFilepath( buf ):

View file

@ -186,7 +186,7 @@ class VariablesView( object ):
'balloonexpr': vim.options[ 'balloonexpr' ],
'balloondelay': vim.options[ 'balloondelay' ],
}
vim.options[ 'balloonexpr' ] = 'vimspector#internal#balloon#BalloonExpr()'
vim.options[ 'balloonexpr' ] = 'vimspector#internal#balloon#HoverTooltip()'
vim.options[ 'balloondelay' ] = 250
if has_balloon:
@ -282,7 +282,7 @@ class VariablesView( object ):
self._variable_eval_view = None
return ''
def VariableEval(self, frame, expression):
def VariableEval(self, frame, expression, is_hover):
"""Callback to display variable under cursor `:h ballonexpr`"""
if not self._connection:
return ''
@ -291,8 +291,7 @@ class VariablesView( object ):
body = message[ 'body' ]
self._variable_eval = Scope(body)
float_win_id = vim.eval("vimspector#internal#balloon#CreateTooltip()")
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
@ -318,7 +317,7 @@ class VariablesView( object ):
def failure_handler( reason, message ):
display = [ reason ]
utils.DisplayBaloon( self._is_term, display )
utils.DisplayBaloon( self._is_term, display, is_hover )
# Send async request
self._connection.DoRequest( handler, {
@ -331,7 +330,7 @@ class VariablesView( object ):
}, failure_handler )
# Return working (meanwhile)
return '...'
return ''
def AddWatch( self, frame, expression ):
watch = {