Add tab completion for $PSBoundParameters.Keys switch cases and access patterns by yotsuda · Pull Request #26483 · PowerShell/PowerShell
added 2 commits
When working with $PSBoundParameters, tab completion now suggests parameter
names from the enclosing function or scriptblock's param block in the
following scenarios:
- switch ($PSBoundParameters.Keys) { <Tab> }
- $PSBoundParameters.ContainsKey('<Tab>')
- $PSBoundParameters['<Tab>']
- $PSBoundParameters.Remove('<Tab>')
This helps prevent typos when writing code that checks or accesses
bound parameter names.
Fixes PowerShell#25349
iSazonov
added
the
CL-General
label
yotsuda
marked this pull request as ready for review
- Remove useless initialization of result variable in CompleteAgainstPSBoundParametersAccess - Extract duplicate ParamBlock finding logic into FindNearestParamBlock helper method This refactoring improves code maintainability by reducing duplication between CompleteAgainstSwitchCaseCondition and CompleteAgainstPSBoundParametersAccess methods.
- Create CreateParameterCompletionResults helper method to reduce code duplication - Consolidate completion result generation logic between CompleteAgainstSwitchCaseCondition and CompleteAgainstPSBoundParametersAccess - Add optional quoteChar parameter to support both quoted and unquoted completion This addresses the second Copilot code review feedback and improves code maintainability.
Addresses review feedback to test all code paths for non-PSBoundParameters variables. The original single negative test is now split into four separate tests covering indexer, ContainsKey, Remove, and double-quoted string access patterns.
yotsuda
deleted the
feature/switch-psboundparameters-completion
branch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters