-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Add completion single/double quote support for -Noun
parameter
#24977
Add completion single/double quote support for -Noun
parameter
#24977
Conversation
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
@ArmaanMcleod Please look failed tests. It seems previously had fake ordering for CompletionResult type. |
@iSazonov It looks like tests need to exclude Gridview cmdlets for Mac and Linux, hench test failures. These cmdlets only available on Windows. I will fix this. |
…k for different operation systems
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
@iSazonov I think it should be fine now. Thanks for the help. I ran tests on Windows and Linux and it seems to be fine, hoping CI lets it go through 😄. |
@@ -1724,7 +1724,7 @@ public IEnumerable<CompletionResult> CompleteArgument( | |||
private static SortedSet<string> GetCommandNouns(IDictionary fakeBoundParameters) | |||
{ | |||
Collection<CommandInfo> commands = CompletionCompleters.GetCommandInfo(fakeBoundParameters, "Module", "Verb"); | |||
SortedSet<string> nouns = new(StringComparer.OrdinalIgnoreCase); | |||
SortedSet<string> nouns = new(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If cmdlet names are case-insensetive on all OS-s this must be case-insensetive too. I think we should think about fixing tests only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep I agree, although to completer it does not make a difference. I have updated code & test. Only way is to use sorted set in the test becauseSort-Object -Unique
gives different ordering on Linux. I think this is fine because it is an accurate comparison anyways.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
📣 Hey @ArmaanMcleod, how did we do? We would love to hear your feedback with the link below! 🗣️ 🔗 https://aka.ms/PSRepoFeedback |
PR Summary
Use
CompletionCompleters.GetMatchingResults
inNounArgumentCompleter
so-Noun
parameter forGet-Command
has support for single/double quotes.Also made the following improvements:
-Verb
is used, only get nouns which are possible with the following verbs.SortedSet<string>
withStringComparer.IgnoreCase
to ensure all nouns are unique and sorted and case insensitive. Also removed previous LINQOrder()
call with this change.Get-Command
logic intoCompletionCompleters.GetCommandInfo
method. This can probably be used elsewhere and potentially reduce duplication of command querying code in completers. Also addusing
for creating powershell instance so its automatically disposed.I also added some tab completion tests which seem to be missing for this completer.
PR Context
Related to #24873
PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.- [ ] Issue filed:
(which runs in a different PS Host).