Skip to content

Commit

Permalink
Merge pull request #777 from puremourning/calculus-expand-arguments
Browse files Browse the repository at this point in the history
Expand references in calculus function arguments
  • Loading branch information
mergify[bot] authored Jun 27, 2023
2 parents 8d9ead4 + 5476ee2 commit 02c8da8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 9 additions & 1 deletion python3/vimspector/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,15 @@ def ExpandReferencesInString( orig_s,
key = e.name + e.arg_hash

if e.name in calculus:
mapping[ key ] = calculus[ e.name ]( *e.args )
# Expand any recursive mappings in the args.... eeeek
new_args = []
for arg in e.args:
new_args.append( ExpandReferencesInObject( arg,
mapping,
calculus,
user_choices ) )

mapping[ key ] = calculus[ e.name ]( *new_args )
_logger.debug( "Put %s into mapping for %s with args %s",
key,
e.name,
Expand Down
10 changes: 7 additions & 3 deletions tests/python/Test_ExpandReferencesInDict.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,15 @@ def test_ParseVariables( self ):
'in': {
'variables_list': {
'not_in_list': '${is_in_list( "x", [ "y", "z" ] )}',
'in_list': '${is_in_list( "x", [ "y", "x", "z" ] )}',
'in_list': '${is_in_list( "x", [ "${why}", "x", "z" ] )}',
'not_in_listj#json': '${is_in_list( "x", [ "y", "z" ] )}',
'in_listj#json': '${is_in_list( "x", [ "y", "x", "z" ] )}',
'in_listj#json':
'${is_in_list( "x", [ "${why}", "x", "${zed}" ] )}',
},
'mapping': {
'why': 'y',
'zed': 'z'
},
'mapping': {},
'calculus': {
'is_in_list':
lambda needle, haystack: 'true' if needle in haystack else 'false'
Expand Down

0 comments on commit 02c8da8

Please sign in to comment.