-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Enable completions for blank between comma and something #17078
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
Enable completions for blank between comma and something #17078
Conversation
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
@MartinGC94, can you please take a quick look at this PR and see if there could be any unwanted side effects after adding |
The code doesn't work. |
@MartinGC94 Thanks for catching it! Just tried and found that |
No this PR doesn't seem to fix anything. |
@daxian-dbw @MartinGC94 Thank you for your reply and I am sorry for my mistake. I have tested it again. It works for the following commands:
But it does not work, as you say, for Why? I think it is because the Actually, my motive in the first place is to fix Additionally, I just care about the Based on the above, I would like to propose the following fixes:
|
Yeah that sounds right, it did look like there was some Enum related code when I stepped through it yesterday. The only problem with a partial fix is that it causes the tab completion code to throw when you try with Enums and ideally it would never throw but throwing doesn't cause any issues as far as I know. |
c609f10
to
01e4800
Compare
Thank you for your advice. I have fixed it this time for sur... probably:smile:. Please review the code. |
src/System.Management.Automation/engine/CommandCompletion/CompletionAnalysis.cs
Outdated
Show resolved
Hide resolved
It looks good now. If you want to also fix it with a space between the comma and cursor you can change line 4128 in CompletionCompleters from
This also fixes the scenario where you move the cursor between a parameter with a colon and a current value like: |
01e4800
to
86c28c6
Compare
Updated @MartinGC94's suggested lines (thanks!) and test cases. |
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
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.
LGTM. Made a couple updates on the comments.
🎉 Handy links: |
PR Summary
Tab completions for a blank between a comma and something (e.g. parameter) does not work.
For example, the No. 1 in the following cases works well, but the No. 2 does not:
lastAst
lastAst is
Get-Command -Type Alias,<tab>
Get-Command -Type Alias,<tab> -All
That is because the tab completion is triggered if the
lastAst
isErrorExpressionAst
. Not triggered ifArrayLiteralAst
. There are same issues other than theGet-Command
, for example,dir
(Get-ChildItem
),Get-Alias
,Get-Module
, etc.I have fixed the condition of triggering the tab completion. It is triggered if the
lastAst
isErrorExpressionAst
orArrayLiteralAst
.PR Context
It helps us to modify such an array, especially when we use Alt+a key (SelectCommandArguments).
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.