-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Description
Similar to #9881, while attempting to tab complete a variable reference, at least curly quotes (I've also determined en-dash/em-dash too) do not cause an escape to the ${ } notation.
Steps to reproduce
${test`u{2018}var} = 'Hello World'
$t # press tab for completion until `test‘var` appearsExpected behavior
${test‘var}
Actual behavior
$test‘varI believe this is part of the issue:
PowerShell/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs
Lines 4565 to 4566 in 981c990
| private static readonly char[] s_charactersRequiringQuotes = new char[] { | |
| '-', '`', '&', '@', '\'', '"', '#', '{', '}', '(', ')', '$', ',', ';', '|', '<', '>', ' ', '.', '\\', '/', '\t', '^', |
I think this is inadequate to catch the conditions that require when the ${ } notation is needed, but the above constant appears to be used for more than just that. The list of characters that require the ${ } notation is much larger and more complicated. If regex could be used, the following might be more accurate for when to require the ${ } : ^(?:[^$^\w?:]|[$^?].)|.(?:::|[^\w?:]) This would return a MATCH when ${ } is required. Examples:
$ false
$$ true
^ false
^^ true
? false
?? true
_? false
:: false
a:: true
test‘var true
Environment data
This particular example was captured with 6.2.0 on Win 10 Pro 18922 (Insiders)
Edit: improved performance of the regex example.