TabExpansionPlusPlus
TabExpansionPlusPlus copied to clipboard
New-CompletionResult does not quote ProviderItems with spaces
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?
No particular reason - I probably assumed that if you used:
[System.Management.Automation.CompletionCompleters]::CompleteFileName($pattern)
that there was no need.
The use case is to for example complete
git add
Should I use CompleteFileName there once per file instead of using new-completionresult?
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.)