Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tab completion: only complete filenames with wildcard-pattern escaping when binding to [SupportsWildcards()] parameters #14149

Open
mklement0 opened this issue Nov 19, 2020 · 2 comments
Labels
Issue-Enhancement the issue is more of a feature request than a bug

Comments

@mklement0
Copy link
Contributor

Summary of the new feature/enhancement

Note:

  • The problem surfaces whenever file / directory names containing [ and ] are completed.

  • E.g., a file literally named foo[1].txt typically tab-completes as foo`[1`].txt rather than to the actual name, using the escaping rules of a wildcard pattern.

Currently, the escaping logic when filenames are tab-completed appears to be as follows:

  • Escape by default,

  • except when binding to a parameter literally named -LiteralPath (using that name as an alias is not recognized).

Instead, I propose the following logic:

  • Do not escape by default,

  • except when the target parameter is decorated with the [SupportsWildCards()] attribute.

Benefits and impact:

  • For command parameters that properly decorate their wildcard-based parameters with this attribute - notably -Path, - the behavior won't change (escaping will be applied); among the built-in cmdlets that seems to be true (which a quick look at Get-Item, Get-ChildItem, Get-Content, and Select-String tells me)

  • In all other cases, unescaped completion will take place.

    • This allows command authors to control how filenames are completed, by indicating explicitly when wildcard support is desired.

    • If they want literal completion, no extra effort is needed, which avoids the awkward current workaround of having to name a parameter -LiteralPath, which isn't always appropriate.

@mklement0 mklement0 added the Issue-Enhancement the issue is more of a feature request than a bug label Nov 19, 2020
@mklement0 mklement0 changed the title Tab completion: only complete filenames with wildcard-pattern escaping when binding to [SupportsWildcards] parameters Tab completion: only complete filenames with wildcard-pattern escaping when binding to [SupportsWildcards()] parameters Nov 20, 2020
@microsoft-github-policy-service microsoft-github-policy-service bot added the Resolution-No Activity Issue has had no activity for 6 months or more label Nov 16, 2023
Copy link
Contributor

This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

@soredake
Copy link

@StevenBucher98 @kilasuit can you reopen this, please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Enhancement the issue is more of a feature request than a bug
Projects
None yet
Development

No branches or pull requests

3 participants