Skip to content

variable tab completion does not escape curly quotes, potentially others #10006

@msftrncs

Description

@msftrncs

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` appears

Expected behavior

${test‘var}

Actual behavior

$testvar

I believe this is part of the issue:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    In-PRIndicates that a PR is out for the issueIssue-BugIssue has been identified as a bug in the productResolution-No ActivityIssue has had no activity for 6 months or moreWG-Interactive-IntelliSensetab completion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions