Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 16, 2025

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:

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:

Get-GitHubLicense @params | Where-Object { $_.Name -like $pattern } | ForEach-Object {
    [System.Management.Automation.CompletionResult]::new($_.Name, $_.Name, 'ParameterValue', $_.Name)
}

After:

$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.


💡 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 in the docs.

Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] 🩹 [Patch]: Prevent ArgumentCompleters from falling back to the default file path completion 🩹 [Patch]: Prevent ArgumentCompleters from falling back to the default file path completion Sep 16, 2025
@Copilot Copilot AI requested a review from MariusStorhaug September 16, 2025 09:12
@MariusStorhaug MariusStorhaug marked this pull request as ready for review September 16, 2025 09:32
@MariusStorhaug MariusStorhaug requested a review from a team as a code owner September 16, 2025 09:32
@Copilot Copilot AI review requested due to automatic review settings September 16, 2025 09:32
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.

Pull Request Overview

This PR addresses an issue where PowerShell argument completers would fall back to file path completion when no valid argument matches were found. This created a confusing user experience where invalid input would show local files and folders instead of no completions.

  • Modified 34 argument completers across 14 files to explicitly return $null when no matches are found
  • Added null checks before returning completion results to prevent fallback to default file path completion
  • Maintains existing completion behavior when valid matches exist

Reviewed Changes

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

Show a summary per file
File Description
src/functions/public/Workflows/completers.ps1 Added null checks for workflow name and ID completers
src/functions/public/Variables/completers.ps1 Added null check for variable name completer
src/functions/public/Teams/completers.ps1 Added null checks for team slug completers
src/functions/public/Secrets/completers.ps1 Added null check for secret name completer
src/functions/public/Repositories/completers.ps1 Added null checks for multiple repository-related completers
src/functions/public/Repositories/Permissions/completers.ps1 Added null check for permission level completer
src/functions/public/Permission/completers.ps1 Added null checks for permission definition completers
src/functions/public/Organization/completers.ps1 Added null checks for organization name completers
src/functions/public/License/completers.ps1 Added null check for license name completer
src/functions/public/Gitignore/completers.ps1 Added null check for gitignore template completer
src/functions/public/Environments/completers.ps1 Added null checks for environment name completers
src/functions/public/Config/completers.ps1 Added null checks for configuration value completers
src/functions/public/Auth/Context/completers.ps1 Added null check for context name completer
src/completers.ps1 Added null checks for app installation completers

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@MariusStorhaug MariusStorhaug merged commit 002492b into main Sep 16, 2025
2 checks passed
@MariusStorhaug MariusStorhaug deleted the copilot/fix-514 branch September 16, 2025 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

🩹 [Patch]: Prevent ArgumentCompleters from falling back to the default file path completion
2 participants