Fix balloons in the GUI

This commit is contained in:
Ben Jackson 2019-02-15 13:19:13 +00:00
commit c684fa0cbb
2 changed files with 11 additions and 5 deletions

View file

@ -343,3 +343,11 @@ def ExpandReferencesInDict( obj, mapping, **kwargs ):
for k in obj.keys(): for k in obj.keys():
obj[ k ] = expand_refs_in_object( obj[ k ] ) obj[ k ] = expand_refs_in_object( obj[ k ] )
def DisplayBaloon( is_term, display ):
if not is_term:
display = '\n'.join( display )
vim.eval( "balloon_show( {0} )".format(
json.dumps( display ) ) )

View file

@ -14,7 +14,6 @@
# limitations under the License. # limitations under the License.
import vim import vim
import json
import logging import logging
from collections import namedtuple from collections import namedtuple
from functools import partial from functools import partial
@ -85,6 +84,7 @@ class VariablesView( object ):
self._oldoptions[ 'balloonevalterm' ] = vim.options[ 'balloonevalterm' ] self._oldoptions[ 'balloonevalterm' ] = vim.options[ 'balloonevalterm' ]
vim.options[ 'balloonevalterm' ] = True vim.options[ 'balloonevalterm' ] = True
self._is_term = not bool( int( vim.eval( "has( 'gui_running' )" ) ) )
def Clear( self ): def Clear( self ):
with utils.ModifiableScratchBuffer( self._vars.win.buffer ): with utils.ModifiableScratchBuffer( self._vars.win.buffer ):
@ -356,13 +356,11 @@ class VariablesView( object ):
'Type: ' + body.get( 'type', '<unknown>' ), 'Type: ' + body.get( 'type', '<unknown>' ),
'Value: ' + result 'Value: ' + result
] ]
vim.eval( "balloon_show( {0} )".format( utils.DisplayBaloon( self._is_term, display )
json.dumps( display ) ) )
def failure_handler( reason, message ): def failure_handler( reason, message ):
display = [ reason ] display = [ reason ]
vim.eval( "balloon_show( {0} )".format( utils.DisplayBaloon( self._is_term, display )
json.dumps( display ) ) )
self._connection.DoRequest( handler, { self._connection.DoRequest( handler, {