Skip to content

PowerShell completion generator: correctness bugs and feature parity gaps #538

Description

@stalep

Summary

The PowerShellCompletionGenerator has several correctness bugs and is missing features that all other generators (bash, zsh, fish) support. Test coverage is also significantly weaker than the other shells.

Correctness Bugs

1. Dynamic generator tokenization breaks on quoted arguments

$commandAst.ToString().Split(' ') splits on spaces, which breaks quoted arguments:

# User types: mycli --message "hello world"
# Split produces: mycli, --message, "hello, world"  (WRONG)

Fix: Use $commandAst.CommandElements which provides proper tokenization.

2. Program name not quoted in dynamic generator

& programName --aesh-complete breaks if the program name contains spaces. Should be & 'programName'.

3. Missing property option filtering

isProperty() is never checked. @OptionGroup properties are emitted as regular options. All other generators skip property options.

4. Error messages omit pwsh

AeshRuntimeRunner.java lines 508, 519, 652 say "Supported: bash, zsh, fish" but omit pwsh.

5. System.lineSeparator() vs "\n"

The generator uses System.lineSeparator() which produces \r\n on Windows. All other generators use "\n". Can cause issues when script is generated on Windows but used on Linux pwsh.

Feature Parity Gaps

All of the following are supported by bash, zsh, and fish generators but missing from PowerShell:

Feature Impact
Option aliases (getAliases()) --config not suggested if only --configuration emitted
Short names (shortName()) -v never offered alongside --verbose
Negatable options (isNegatable()) --no-verbose never emitted
Value completion (allowedValues/defaultValues) Enum values not listed as candidates
File options (isTypeAssignableByResourcesOrFile()) No Get-ChildItem fallback for file-type options
Arguments (@Argument/@Arguments) Positional arguments completely ignored

Test Coverage Gaps

What Bash Zsh Fish PowerShell
Option aliases Yes Yes Yes No
Negatable options Yes Yes Yes No
Value completion Yes Yes Yes No
File options Yes Yes implicit No
Multi-arguments Yes Yes Yes No
--aesh-completion --static Yes Yes Yes No
detectShell() unit tests No
Integration (run actual shell) No No No No

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions