From 584b42ed4fe8146247ad450162cd83af32dd853f Mon Sep 17 00:00:00 2001 From: Hosh Sadiq Date: Mon, 2 Jan 2023 14:47:30 +0000 Subject: [PATCH] Force ForEach-Object to return array in pwsh completion Fixes #1847 Merge https://github.com/spf13/cobra/pull/1850 --- templates/completion.pwsh.gotmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/completion.pwsh.gotmpl b/templates/completion.pwsh.gotmpl index 7b9b16d..681d6fa 100644 --- a/templates/completion.pwsh.gotmpl +++ b/templates/completion.pwsh.gotmpl @@ -97,7 +97,7 @@ Register-ArgumentCompleter -CommandName '{{ .CMDVarName }}' -ScriptBlock { } $Longest = 0 - $Values = $Out | ForEach-Object { + [Array]$Values = $Out | ForEach-Object { #Split the output in name and description $Name, $Description = $_.Split("`t",2) __{{ .CMDVarName }}_debug "Name: $Name Description: $Description"