From b9ed7f34b46f30d451a174005b64fd151ac14764 Mon Sep 17 00:00:00 2001 From: dsych Date: Thu, 24 Dec 2020 00:08:02 -0500 Subject: [PATCH] removing redundant name for simple types, shortening variable type to 20 char and variable value to 100 chars to avoid overflowing tooltip window if the wrapped line is longer than the max size of the tooltip --- python3/vimspector/variables.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/python3/vimspector/variables.py b/python3/vimspector/variables.py index a81991a..b30c473 100644 --- a/python3/vimspector/variables.py +++ b/python3/vimspector/variables.py @@ -276,7 +276,7 @@ class VariablesView( object ): utils.ClearBuffer( self._variable_eval_view.buf ) icon = '+' if self._variable_eval.IsExpandable() and not self._variable_eval.IsExpanded() else '-' - self._DrawVariables( self._variable_eval_view, self._variable_eval.variables, 2 ) + self._DrawVariables( self._variable_eval_view, self._variable_eval.variables, 2 , True) def _CleanUpTooltip(self): # remove reference to old tooltip window @@ -312,7 +312,7 @@ class VariablesView( object ): else: # 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({'name': expression, 'type': body['type'], 'value': body['result']})] + self._variable_eval.variables = [Variable({ 'type': body['type'], 'value': body['result']})] self._DrawEval() @@ -439,9 +439,18 @@ class VariablesView( object ): }, } ) - def _DrawVariables( self, view, variables, indent ): + def _DrawVariables( self, view, variables, indent, is_short = False ): assert indent > 0 for variable in variables: + type_ = variable.variable.get( 'type', '' ) + value = variable.variable.get( 'value', '' ) + + if is_short: + if( len(type_) > 20): + type_ = type_[0:16] + " ..." + if( len(value) > 100 ): + value = value[0:96] + " ..." + line = utils.AppendToBuffer( view.buf, '{indent}{marker}{icon} {name} ({type_}): {value}'.format( @@ -450,14 +459,13 @@ class VariablesView( object ): marker = '*' if variable.changed else ' ', icon = '+' if ( variable.IsExpandable() and not variable.IsExpanded() ) else '-', - name = variable.variable[ 'name' ], - type_ = variable.variable.get( 'type', '' ), - value = variable.variable.get( 'value', - '' ) ).split( '\n' ) ) + name = variable.variable.get( 'name', '' ), + type_ = type_, + value = value ).split( '\n' )) view.lines[ line ] = variable if variable.ShouldDrawDrillDown(): - self._DrawVariables( view, variable.variables, indent + 2 ) + self._DrawVariables( view, variable.variables, indent + 2, is_short ) def _DrawScopes( self ): # FIXME: The drawing is dumb and draws from scratch every time. This is