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

This commit is contained in:
dsych 2020-12-24 00:08:02 -05:00 • committed by Ben Jackson
commit b9ed7f34b4

View file

@ -276,7 +276,7 @@ class VariablesView( object ):
utils.ClearBuffer( self._variable_eval_view.buf ) utils.ClearBuffer( self._variable_eval_view.buf )
icon = '+' if self._variable_eval.IsExpandable() and not self._variable_eval.IsExpanded() else '-' 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): def _CleanUpTooltip(self):
# remove reference to old tooltip window # remove reference to old tooltip window
@ -312,7 +312,7 @@ class VariablesView( object ):
else: else:
# in case that there is nothing to expand, we need to simulate a response from 'variables' request # in case that there is nothing to expand, we need to simulate a response from 'variables' request
# it returns [Variable] # 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() 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 assert indent > 0
for variable in variables: for variable in variables:
type_ = variable.variable.get( 'type', '' )
value = variable.variable.get( 'value', '<unknown>' )
if is_short:
if( len(type_) > 20):
type_ = type_[0:16] + " ..."
if( len(value) > 100 ):
value = value[0:96] + " ..."
line = utils.AppendToBuffer( line = utils.AppendToBuffer(
view.buf, view.buf,
'{indent}{marker}{icon} {name} ({type_}): {value}'.format( '{indent}{marker}{icon} {name} ({type_}): {value}'.format(
@ -450,14 +459,13 @@ class VariablesView( object ):
marker = '*' if variable.changed else ' ', marker = '*' if variable.changed else ' ',
icon = '+' if ( variable.IsExpandable() icon = '+' if ( variable.IsExpandable()
and not variable.IsExpanded() ) else '-', and not variable.IsExpanded() ) else '-',
name = variable.variable[ 'name' ], name = variable.variable.get( 'name', '' ),
type_ = variable.variable.get( 'type', '' ), type_ = type_,
value = variable.variable.get( 'value', value = value ).split( '\n' ))
'<unknown>' ) ).split( '\n' ) )
view.lines[ line ] = variable view.lines[ line ] = variable
if variable.ShouldDrawDrillDown(): if variable.ShouldDrawDrillDown():
self._DrawVariables( view, variable.variables, indent + 2 ) self._DrawVariables( view, variable.variables, indent + 2, is_short )
def _DrawScopes( self ): def _DrawScopes( self ):
# FIXME: The drawing is dumb and draws from scratch every time. This is # FIXME: The drawing is dumb and draws from scratch every time. This is