You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found that during formatting, some keywords aren't separated from leading braces (while), and some are seemingly ignored entirely (until). Also, unary operators (-not, -bnot, etc.) aren't separated with whitespace the same way as binary operators (-eq, -like, etc.).
Steps to reproduce
Paste the following into a script
Use Invoke-Formatter or the PowerShell VSCode extension to format the document
Roughly the following output. Some is dependent on brace style (OTBS in this case), but all rules for inserting whitespace around keywords and operators should be enabled.
if (-not$false) {
do {
'Hello!'
} until (
$True
)
do {
'Oh, hi!'
} while (
-not$True
)
while (-not$True) {
"This won't show up."
}
}
Actual behavior
if (-not$false) { # -not isn't separated by whitespacedo {
'Hello!'
}until( # no whitespace around Until$True
)
do {
'Oh, hi!'
}while ( # only trailing whitespace for While-not$True# no separation
)
while (-not$True) { # no separation for -not and -bnot"This won't show up."
}
}
Suggest to try the new 1.24.0 release, which is in the preview version of the vc code ps extension. some things around whitespaces are tweaked but not your cases I think. UseConsistentWhitespace has CheckOperator option, which could be enhanced with your -not$false case and keywords like do-while should probably be a new option
Suggest to try the new 1.24.0 release, which is in the preview version of the vc code ps extension. some things around whitespaces are tweaked but not your cases I think. UseConsistentWhitespace has CheckOperator option, which could be enhanced with your -not$false case and keywords like do-while should probably be a new option
Thanks for the reply. I've tried 1.24.0 with the same results, so I think it might just be something that needs to be added like you said.
I found that during formatting, some keywords aren't separated from leading braces (
while
), and some are seemingly ignored entirely (until
). Also, unary operators (-not
,-bnot
, etc.) aren't separated with whitespace the same way as binary operators (-eq
,-like
, etc.).Steps to reproduce
Expected behavior
Roughly the following output. Some is dependent on brace style (OTBS in this case), but all rules for inserting whitespace around keywords and operators should be enabled.
Actual behavior
Environment data
1.23.0 is the version included with the current (2025.0.0) VSCode PowerShell extension. I've also installed and tested 1.24.0 with the same results.
The text was updated successfully, but these errors were encountered: