Add a marker when a variable value changes
This commit is contained in:
parent
39212f4ffc
commit
4b7fc83ce3
1 changed files with 28 additions and 4 deletions
|
|
@ -64,26 +64,44 @@ class Scope( Expandable ):
|
||||||
def VariablesReference( self ):
|
def VariablesReference( self ):
|
||||||
return self.scope.get( 'variablesReference', 0 )
|
return self.scope.get( 'variablesReference', 0 )
|
||||||
|
|
||||||
|
def Update( self, scope ):
|
||||||
|
self.scope = scope
|
||||||
|
|
||||||
|
|
||||||
class WatchResult( Expandable ):
|
class WatchResult( Expandable ):
|
||||||
"""Holds the result of a Watch expression with expand/collapse."""
|
"""Holds the result of a Watch expression with expand/collapse."""
|
||||||
def __init__( self, result: dict ):
|
def __init__( self, result: dict ):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.result = result
|
self.result = result
|
||||||
|
self.changed = False
|
||||||
|
|
||||||
def VariablesReference( self ):
|
def VariablesReference( self ):
|
||||||
return self.result.get( 'variablesReference', 0 )
|
return self.result.get( 'variablesReference', 0 )
|
||||||
|
|
||||||
|
def Update( self, result ):
|
||||||
|
self.changed = False
|
||||||
|
if self.result[ 'result' ] != result[ 'result' ]:
|
||||||
|
self.changed = True
|
||||||
|
self.result = result
|
||||||
|
|
||||||
|
|
||||||
class Variable( Expandable ):
|
class Variable( Expandable ):
|
||||||
"""Holds one level of an expanded value tree. Also itself expandable."""
|
"""Holds one level of an expanded value tree. Also itself expandable."""
|
||||||
def __init__( self, variable: dict ):
|
def __init__( self, variable: dict ):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.variable = variable
|
self.variable = variable
|
||||||
|
self.changed = False
|
||||||
|
|
||||||
def VariablesReference( self ):
|
def VariablesReference( self ):
|
||||||
return self.variable.get( 'variablesReference', 0 )
|
return self.variable.get( 'variablesReference', 0 )
|
||||||
|
|
||||||
|
def Update( self, variable ):
|
||||||
|
self.changed = False
|
||||||
|
if self.variable[ 'value' ] != variable[ 'value' ]:
|
||||||
|
self.changed = True
|
||||||
|
self.variable = variable
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Watch:
|
class Watch:
|
||||||
"""Holds a user watch expression (DAP request) and the result (WatchResult)"""
|
"""Holds a user watch expression (DAP request) and the result (WatchResult)"""
|
||||||
|
|
@ -273,7 +291,7 @@ class VariablesView( object ):
|
||||||
|
|
||||||
def _UpdateWatchExpression( self, watch: Watch, message: dict ):
|
def _UpdateWatchExpression( self, watch: Watch, message: dict ):
|
||||||
if watch.result is not None:
|
if watch.result is not None:
|
||||||
watch.result.result = message[ 'body' ]
|
watch.result.Update( message[ 'body' ] )
|
||||||
else:
|
else:
|
||||||
watch.result = WatchResult( message[ 'body' ] )
|
watch.result = WatchResult( message[ 'body' ] )
|
||||||
|
|
||||||
|
|
@ -327,8 +345,9 @@ class VariablesView( object ):
|
||||||
for variable in variables:
|
for variable in variables:
|
||||||
line = utils.AppendToBuffer(
|
line = utils.AppendToBuffer(
|
||||||
view.win.buffer,
|
view.win.buffer,
|
||||||
'{indent}{icon} {name} ({type_}): {value}'.format(
|
'{indent}{marker}{icon} {name} ({type_}): {value}'.format(
|
||||||
indent = ' ' * indent,
|
indent = ' ' * indent,
|
||||||
|
marker = '*' if variable.changed else ' ',
|
||||||
icon = '+' if ( variable.IsExpandable()
|
icon = '+' if ( variable.IsExpandable()
|
||||||
and not variable.IsExpandedByUser() ) else '-',
|
and not variable.IsExpandedByUser() ) else '-',
|
||||||
name = variable.variable[ 'name' ],
|
name = variable.variable[ 'name' ],
|
||||||
|
|
@ -394,7 +413,12 @@ class VariablesView( object ):
|
||||||
if result_str is None:
|
if result_str is None:
|
||||||
result_str = '<unknown>'
|
result_str = '<unknown>'
|
||||||
|
|
||||||
line = '{0}{1} Result: {2}'.format( ' ' * indent, icon, result_str )
|
line = '{indent}{marker}{icon} Result: {result}'.format(
|
||||||
|
indent = ' ' * indent,
|
||||||
|
marker = '*' if watch.result.changed else ' ',
|
||||||
|
icon = icon,
|
||||||
|
result = result_str )
|
||||||
|
|
||||||
line = utils.AppendToBuffer( self._watch.win.buffer, line.split( '\n' ) )
|
line = utils.AppendToBuffer( self._watch.win.buffer, line.split( '\n' ) )
|
||||||
self._watch.lines[ line ] = watch.result
|
self._watch.lines[ line ] = watch.result
|
||||||
|
|
||||||
|
|
@ -413,7 +437,7 @@ class VariablesView( object ):
|
||||||
found = False
|
found = False
|
||||||
for index, v in enumerate( parent.variables ):
|
for index, v in enumerate( parent.variables ):
|
||||||
if v.variable[ 'name' ] == variable_body[ 'name' ]:
|
if v.variable[ 'name' ] == variable_body[ 'name' ]:
|
||||||
v.variable = variable_body
|
v.Update( variable_body )
|
||||||
variable = v
|
variable = v
|
||||||
found = True
|
found = True
|
||||||
break
|
break
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue