Hi!
I noticed that syntax highlighting does not work properly for control statements used on the right-hand side of assignments.
I tried a small fix and for now it seems to work fine without unexpected side-effects.
$x = if ($a) { 1 } else { 2 }
$x = switch ($v) { 1 { 'one' } default { 'other' } }
$x = foreach ($i in 1..3) { $i * 2 }
$x = try { Get-Thing } catch { $null }
My testing is limited, so I can't say anything definitive about edge cases or possible performance implications.
Here's my change:
--- PowerShell.sublime-syntax
+++ PowerShell.sublime-syntax
@@ -948,8 +948,11 @@
in-assignment:
- include: pop-end-of-command
# INFO: Someday maybe we can nix the workflow stuff
- include: workflow-execution-contexts
+ - include: conditionals
+ - include: loops
+ - include: exceptions
- include: expressions
redirection:
I'm not opening this as a PR because I don't know how to write syntax tests, and I'm unsure if this needs to be implemented differently as a proper fix.
Thanks for your work!
Best Regards
Steve
Hi!
I noticed that syntax highlighting does not work properly for control statements used on the right-hand side of assignments.
I tried a small fix and for now it seems to work fine without unexpected side-effects.
My testing is limited, so I can't say anything definitive about edge cases or possible performance implications.
Here's my change:
I'm not opening this as a PR because I don't know how to write syntax tests, and I'm unsure if this needs to be implemented differently as a proper fix.
Thanks for your work!
Best Regards
Steve