TabExpansionPlusPlus icon indicating copy to clipboard operation
TabExpansionPlusPlus copied to clipboard

New-CompletionResult does not quote ProviderItems with spaces

Open powercode opened this issue 11 years ago • 3 comments

We add single quotes when the CompletionResultType is ParameterValue, but when writing a completer that returns results with type ProviderContainer and ProviderItem, I noticed that they don't get quoted.

What is the reason for only escaping items of type ProviderValue?

powercode avatar Dec 12 '13 08:12 powercode

No particular reason - I probably assumed that if you used:

[System.Management.Automation.CompletionCompleters]::CompleteFileName($pattern)

that there was no need.

lzybkr avatar Dec 12 '13 19:12 lzybkr

The use case is to for example complete git add with the output from git ls-files --modified.

Should I use CompleteFileName there once per file instead of using new-completionresult?

powercode avatar Dec 12 '13 21:12 powercode

If you don't use CompleteFileName, then the option to use relative vs. full filenames won't do anything without support in New-CompletionResult. Maybe it makes sense to add a new function New-FileCompletionResult that does extra work like this.

I'm not sure how well the builtin function handles funky names - e.g. it escapes square braces if the filename is not an argument to -LiteralPath, but that is actually the wrong thing to do for native commands (we can call that a PowerShell bug.)

lzybkr avatar Dec 12 '13 21:12 lzybkr