Skip to content

Filter out the nested modules of PSReadLine from module name tab completion #24910

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

Merged
merged 3 commits into from
Feb 18, 2025

Conversation

daxian-dbw
Copy link
Member

PR Summary

When doing module name completion such as Get-Module mic<tab> or Get-Module psr<tab>, you will see Microsoft.PowerShell.PSReadLine2 as the result of completion. Microsoft.PowerShell.PSReadLine2 is a nested module of PSReadLine, which shouldn't be returned by completion. It's returned because the completion happens in PSReadLine's context (using PSReadLine's SessionState as the EngineSessionState) and hence its nested modules are visible to the tab completion.

completion

This PR filters out the nested modules of PSReadLine from the tab completion results. It's intentional to not hard code the name 'PSReadLine' in the change, so that in case the tab completion is triggered from within a different module, its nested modules can also be filtered out.

PR Checklist

@daxian-dbw daxian-dbw requested a review from Copilot January 31, 2025 19:34
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs:474

  • [nitpick] The variable name 'nestedModulesToFilterOut' is a bit lengthy and could be simplified to 'filteredNestedModules' for better readability.
HashSet<PSModuleInfo> nestedModulesToFilterOut = null;

@daxian-dbw daxian-dbw added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Jan 31, 2025
@daxian-dbw
Copy link
Member Author

/azp run

Copy link

Azure Pipelines successfully started running 4 pipeline(s).

@microsoft-github-policy-service microsoft-github-policy-service bot added the Review - Needed The PR is being reviewed label Feb 8, 2025
Copy link
Collaborator

@iSazonov iSazonov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one style comment.

@iSazonov

This comment was marked as outdated.

This comment was marked as outdated.

@microsoft-github-policy-service microsoft-github-policy-service bot removed the Review - Needed The PR is being reviewed label Feb 15, 2025
@daxian-dbw daxian-dbw merged commit 4d174fc into PowerShell:master Feb 18, 2025
39 of 41 checks passed
@daxian-dbw daxian-dbw deleted the comp-nested-modules branch February 18, 2025 18:13
Copy link
Contributor

microsoft-github-policy-service bot commented Feb 18, 2025

📣 Hey @daxian-dbw, how did we do? We would love to hear your feedback with the link below! 🗣️

🔗 https://aka.ms/PSRepoFeedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants