diff --git a/cmd/carapace/cmd/lazyinit/powershell.go b/cmd/carapace/cmd/lazyinit/powershell.go index cbd93b9e5f..ea8750b50e 100644 --- a/cmd/carapace/cmd/lazyinit/powershell.go +++ b/cmd/carapace/cmd/lazyinit/powershell.go @@ -11,22 +11,21 @@ func Powershell(completers []string) string { $_carapace_lazy = { param($wordToComplete, $commandAst, $cursorPosition) - $completer = $commandAst.CommandElements[0].Value + $completer = $commandAst.CommandElements[0].Value.trimend(".exe") carapace $completer powershell | Out-String | Invoke-Expression & (Get-Item "Function:_${completer}_completer") $wordToComplete $commandAst $cursorPosition } %v ` - prefix := "# " + prefix := " # " if runtime.GOOS == "windows" { prefix = "" } complete := make([]string, 0, len(completers)*2) for _, completer := range completers { - complete = append(complete, fmt.Sprintf(`Register-ArgumentCompleter -Native -CommandName '%v' -ScriptBlock $_carapace_lazy`, completer)) - complete = append(complete, fmt.Sprintf(`%vRegister-ArgumentCompleter -Native -CommandName '%v.exe' -ScriptBlock $_carapace_lazy`, prefix, completer)) + complete = append(complete, fmt.Sprintf(`Register-ArgumentCompleter -Native -ScriptBlock $_carapace_lazy -CommandName '%v'%v,'%v.exe'`, completer, prefix, completer)) } return fmt.Sprintf(snippet, pathSnippet("powershell"), envSnippet("powershell"), strings.Join(complete, "\n")) }