Skip to content

Commit

Permalink
Fix: Remove balloon '...' in windows != code_window
Browse files Browse the repository at this point in the history
Problem: In non-code window, user see a '...' balloon even if python
knows it does not need to work
Solution: use pyeval in vim so that python's knowledge is getting back
from the stack as return value
  • Loading branch information
tinmarino committed Jan 9, 2020
1 parent 68c47ed commit 7f39efc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
7 changes: 4 additions & 3 deletions autoload/vimspector/internal/balloon.vim
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ let s:save_cpo = &cpoptions
set cpoptions&vim
" }}}

" Returns: py.ShowBalloon( winnr, expresssion )
function! vimspector#internal#balloon#BalloonExpr() 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.
py3 _vimspector_session.ShowBalloon( int( vim.eval( 'v:beval_winnr' ) ) + 1,
\ vim.eval( 'v:beval_text' ) )
return '...'
return py3eval('_vimspector_session.ShowBalloon('
\ . 'int( vim.eval( "v:beval_winnr" ) ) + 1,'
\ . 'vim.eval( "v:beval_text" ) )' )
endfunction

" Boilerplate {{{
Expand Down
20 changes: 13 additions & 7 deletions python3/vimspector/debug_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,16 +359,22 @@ def DeleteWatch( self ):
self._variablesView.DeleteWatch()

def ShowBalloon( self, winnr, expression ):
if self._stackTraceView.GetCurrentFrame() is None:
return

if winnr == int( self._codeView._window.number ):
self._variablesView.ShowBalloon( self._stackTraceView.GetCurrentFrame(),
expression )
else:
"""Proxy: ballonexpr -> variables.ShowBallon"""
frame = self._stackTraceView.GetCurrentFrame()
# Check if RIP is in a frame
if frame is None:
self._logger.debug( 'Balloon: Not in a stack frame' )
return ''

# Check if cursor in code window
if winnr != int( self._codeView._window.number ):
self._logger.debug( 'Winnr %s is not the code window %s',
winnr,
self._codeView._window.number )
return ''

# Return variable aware function
return self._variablesView.ShowBalloon( frame, expression )

def ExpandFrameOrThread( self ):
self._stackTraceView.ExpandFrameOrThread()
Expand Down
8 changes: 6 additions & 2 deletions python3/vimspector/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,9 @@ def _ConsumeVariables( self, draw, parent, message ):
draw()

def ShowBalloon( self, frame, expression ):
"""Callback to display variable under cursor `:h ballonexpr`"""
if not self._connection:
return
return ''

def handler( message ):
# TODO: this result count be expandable, but we have no way to allow the
Expand All @@ -366,7 +367,7 @@ def failure_handler( reason, message ):
display = [ reason ]
utils.DisplayBaloon( self._is_term, display )


# Send async request
self._connection.DoRequest( handler, {
'command': 'evaluate',
'arguments': {
Expand All @@ -376,6 +377,9 @@ def failure_handler( reason, message ):
}
}, failure_handler )

# Return working (meanwhile)
return '...'


def SetSyntax( self, syntax ):
if not syntax:
Expand Down

0 comments on commit 7f39efc

Please sign in to comment.