◐ Shell
clean mode source ↗

Add tab completion for $PSBoundParameters.Keys switch cases and access patterns by yotsuda · Pull Request #26483 · PowerShell/PowerShell

added 2 commits

November 19, 2025 12:17
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 iSazonov added the CL-General

Indicates that a PR should be marked as a general cmdlet change in the Change Log

label

Nov 19, 2025
…letionAnalysis.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…letionAnalysis.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…letionAnalysis.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

@yotsuda yotsuda marked this pull request as ready for review

November 19, 2025 09:52

MartinGC94

…letionAnalysis.cs

Co-authored-by: MartinGC94 <42123497+MartinGC94@users.noreply.github.com>
…letionAnalysis.cs

Co-authored-by: MartinGC94 <42123497+MartinGC94@users.noreply.github.com>
…letionAnalysis.cs

Co-authored-by: MartinGC94 <42123497+MartinGC94@users.noreply.github.com>
…letionAnalysis.cs

Co-authored-by: MartinGC94 <42123497+MartinGC94@users.noreply.github.com>
…letionAnalysis.cs

Co-authored-by: MartinGC94 <42123497+MartinGC94@users.noreply.github.com>
…letionAnalysis.cs

Co-authored-by: MartinGC94 <42123497+MartinGC94@users.noreply.github.com>
…letionAnalysis.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…letionAnalysis.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…letionAnalysis.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- 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.

iSazonov

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.

iSazonov

…letionAnalysis.cs

Co-authored-by: Ilya <darpa@yandex.ru>

iSazonov

@yotsuda yotsuda deleted the feature/switch-psboundparameters-completion branch

November 26, 2025 07:04

SIRMARGIN pushed a commit to SIRMARGIN/PowerShell that referenced this pull request

Dec 12, 2025

kilasuit pushed a commit to kilasuit/PowerShell that referenced this pull request

Jan 2, 2026

JustinGrote pushed a commit to JustinGrote/PowerShell that referenced this pull request

Jun 2, 2026