You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🩹 [Patch]: Prevent ArgumentCompleters from falling back to the default file path completion (#515)
This PR addresses an issue where PowerShell argument completers would
fall back to file path completion when no valid argument matches were
found, leading to irrelevant file and folder suggestions.
## Problem
When using argument completion with GitHub PowerShell module commands,
if no matches were found for the typed input, PowerShell would default
to showing file and folder completions from the current directory. This
created a confusing user experience where typing something like:
```powershell
Get-GitHubLicense -Name invalidlicense<TAB>
```
Would show local files and folders instead of no completions, suggesting
invalid options to the user.
## Solution
Updated all 34 argument completers across 14 files to explicitly return
`$null` when no matches are found. The fix follows this pattern:
**Before:**
```powershell
Get-GitHubLicense @params | Where-Object { $_.Name -like $pattern } | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_.Name, $_.Name, 'ParameterValue', $_.Name)
}
```
**After:**
```powershell
$filteredOptions = Get-GitHubLicense @params | Where-Object { $_.Name -like $pattern }
if (-not $filteredOptions) {
return $null
}
$filteredOptions | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_.Name, $_.Name, 'ParameterValue', $_.Name)
}
```
## Result
- ✅ When valid matches exist: Shows appropriate completions as before
- ✅ When no matches exist: No completions shown (cursor stays in place)
- ❌ Previously: Would show irrelevant file/folder completions when no
matches found
This provides a cleaner, more intuitive completion experience that
doesn't suggest invalid options to users.
## Files Modified
All completer files throughout the module structure:
- Core completers in `/src/completers.ps1`
- Function-specific completers in
`/src/functions/public/*/completers.ps1`
Fixes#514.
<!-- START COPILOT CODING AGENT TIPS -->
---
💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
0 commit comments