making sure to open popup relative to cursor
This commit is contained in:
parent
819d6366ac
commit
d2990d7bae
5 changed files with 29 additions and 31 deletions
|
|
@ -524,7 +524,7 @@ function! vimspector#OnBufferCreated( file_name ) abort
|
|||
endfunction
|
||||
|
||||
function! vimspector#ShowTooltip() abort
|
||||
return py3eval('_vimspector_session.ShowTooltip(int( vim.eval( "winnr()" ) ) ,vim.eval( "expand(\"<cexpr>\")" ) )')
|
||||
return py3eval('_vimspector_session.ShowTooltip(int( vim.eval( "winnr()" ) ) ,vim.eval( "expand(\"<cexpr>\")" ), 0)')
|
||||
endfunction
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -30,13 +30,8 @@ function! vimspector#internal#balloon#BalloonExpr() abort
|
|||
endfunction
|
||||
|
||||
" Returns: py.ShowBalloon( winnr, expresssion )
|
||||
function! vimspector#internal#balloon#Tooltip() abort
|
||||
" winnr + 1 because for *no good reason* winnr is 0 based here unlike
|
||||
" everywhere else
|
||||
" int() because for *no good reason* winnr is a string.
|
||||
return py3eval('_vimspector_session.ShowBalloon('
|
||||
\ . 'int( vim.eval( "v:beval_winnr" ) ) + 1,'
|
||||
\ . 'vim.eval( "expand(\"<cexpr>\")" ) )' )
|
||||
function! vimspector#internal#balloon#HoverTooltip() abort
|
||||
return py3eval('_vimspector_session.ShowTooltip(int( vim.eval( "v:beval_winnr" ) ) + 1 ,vim.eval( "v:beval_text"), 1)')
|
||||
endfunction
|
||||
|
||||
|
||||
|
|
@ -47,11 +42,16 @@ function! vimspector#internal#balloon#closeCallback() abort
|
|||
return py3eval('_vimspector_session._CleanUpTooltip()')
|
||||
endfunction
|
||||
|
||||
function! vimspector#internal#balloon#CreateTooltip() abort
|
||||
function! vimspector#internal#balloon#CreateTooltip(is_hover, ...)
|
||||
let body = []
|
||||
if a:0 > 0
|
||||
let body = a:1
|
||||
endif
|
||||
|
||||
if has('nvim')
|
||||
let buf = nvim_create_buf(v:false, v:true)
|
||||
" call nvim_buf_set_option(buf, 'modifiable', v:false)
|
||||
call nvim_buf_set_lines(buf, 0, -1, v:true, [])
|
||||
call nvim_buf_set_lines(buf, 0, -1, v:true, body)
|
||||
|
||||
" default the dimensions for now. they can be easily overwritten later
|
||||
let opts = #{
|
||||
|
|
@ -117,7 +117,7 @@ function! vimspector#internal#balloon#CreateTooltip() abort
|
|||
call vimspector#internal#balloon#closeCallback()
|
||||
endif
|
||||
|
||||
let s:float_win = popup_create([], #{
|
||||
let config = #{
|
||||
\ filter: "MyFilter",
|
||||
\ cursorline: 1,
|
||||
\ wrap: 1,
|
||||
|
|
@ -125,9 +125,14 @@ function! vimspector#internal#balloon#CreateTooltip() abort
|
|||
\ maxwidth: 50,
|
||||
\ maxheight: 5,
|
||||
\ scrollbar: 1,
|
||||
\ moved: "any",
|
||||
\ })
|
||||
" call setbufvar(winbufnr(s:float_win), '&buflisted', 1)
|
||||
\ }
|
||||
if a:is_hover
|
||||
let config['mousemoved'] = "word"
|
||||
let s:float_win = popup_beval(body, config)
|
||||
else
|
||||
let config['moved'] = "any"
|
||||
let s:float_win = popup_atcursor(body, config)
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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 ):
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue