volta icon indicating copy to clipboard operation
volta copied to clipboard

Volta completions not working for PowerShell 7 on Windows 11

Open yu-cn opened this issue 3 years ago • 2 comments

I had added scripts generated by volta completions powershell to Microsoft.PowerShell_profile.ps1 but that not working.

Platform information:

  • Windows 11: 22H2(22621.457)
  • Powershell: 7.2.6
  • Volta: 1.0.8

yu-cn avatar Sep 15 '22 11:09 yu-cn

When you save the completion script, go in and change the $command variable to the below:

$command = @(
    'volta'
    for ($i = 1; $i -lt $commandElements.Count; $i++) {
        $element = $commandElements[$i]
        if ($element -isnot [StringConstantExpressionAst] -or
            $element.StringConstantType -ne [StringConstantType]::BareWord -or
-           $element.Value.StartsWith('-')) {
+           $element.Value.StartsWith('-') -or
+           $element.Value -eq $wordToComplete) {
            break
    }
    $element.Value
}) -join ';'

TheBrenny avatar Jul 15 '23 01:07 TheBrenny

This is most likely an issue with our upstream dependency on Clap, and will hopefully be resolved after we get to the latest version there (#1598).

chriskrycho avatar Dec 20 '23 02:12 chriskrycho