-
Notifications
You must be signed in to change notification settings - Fork 8k
Enable completion of scoped variables without specifying scope #20340
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 completion of scoped variables without specifying scope #20340
Conversation
|
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) |
I'm not sure it's unequivocally useful and/or convenient. It's better to discuss it in a new issue and get WG's opinion.
That seems like an oversight. It would have been handy to have. If you put this in a separate PR then I will review it. |
Variable completion includes variables from the session state so if you declare a global variable: |
|
@theJasonHelmick I see you added the WG reviewed tag. What was the conclusion? Are we good to merge this? |
|
@MartinGC94 Please resolve merge conflicts. |
src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs
Show resolved
Hide resolved
src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs
Show resolved
Hide resolved
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
| if (colon >= 0) | ||
| { | ||
| scopePrefix = wordToComplete.Remove(colon + 1); | ||
| wordToComplete = wordToComplete.Substring(colon + 1); |
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.
I see wordToComplete in line 5282 but now we modify the wordToComplete before use in the line. Is this intentional? Have we tests for the 5282 line?
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.
wordToComplete is modified to remove the scope so in scenarios like: $script:MyVar<Tab> it becomes MyVar. So we can find variables that start with MyVar. My test on line 702 covers this scenario because if we didn't remove the global scope from the input text, it wouldn't be able to find any variables at all.
|
📣 Hey @MartinGC94, how did we do? We would love to hear your feedback with the link below! 🗣️ 🔗 https://aka.ms/PSRepoFeedback |
PR Summary
Changes how completion of variables with scopes are handled, so variables like:
$Global:TestVar = "Hello"can be completed without specifying the scope like this:TestVar<Tab>.Also enabled completion of variables with the
usingscope so this:$TestVar="Hello";$using:Tes<Tab>completes the variable.PR Context
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.(which runs in a different PS Host).