vscode-tcl
vscode-tcl copied to clipboard
Highlight broken when variable surrounded by {}
Hi,
Thanks for a great job!!! But I found a minor bug: Highlight broken when variable surrounded by {}, see the code after the "foreach" block
proc test {blocks {output ""}} {
set a 1
array set done [list]
foreach broken [list a b c] {
if {![info exists done(${broken})]} {
puts "done"
}
}
set b 1 #Highlight broken
puts "bad" #Highlight broken
}
#Highlight broken
proc another_proc {} {
puts "Inside of another block is ok"
}

Thanks, Alex.
Thank you, this one will take a bit of cogitation.
For a little clarification, the issue only seems to occur when setting an array with a variable reference with braces as the array name
so this is ok lappend fred $some_array_name(${some_variable})
as well as this set some_array_name($some_variable) bob
but this breaks things set some_array_name(${some_variable}) bob
so if the array is preceded by a $ then it works but if not then it breaks
# this comment is colored properly
if {${var}} {
# if you are referencing the variable with the $ then the braces are ok
lappend fred $some_array_name(${some_variable})
# setting an array with the array name as a variable reference but without the braces is ok as well
set some_array_name($some_variable) bob
# but setting an array element using a variable reference with braces as the name breaks the formatting
# this line is where it breaks and is similar to the OPs use case
set some_array_name(${some_variable}) bob
} else {
puts "now the else isn't colored properly and other things further down are broken"
}
# this comment is not colored properly