From c7817348618fbc7eedadb3ba56e4784ec12dd4af Mon Sep 17 00:00:00 2001 From: Weicao-CatilGrass <1992414357@qq.com> Date: Sun, 12 Apr 2026 20:50:44 +0800 Subject: Use same suggestion format for PowerShell as Zsh --- mingling_core/tmpls/comps/pwsh.ps1 | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'mingling_core/tmpls') diff --git a/mingling_core/tmpls/comps/pwsh.ps1 b/mingling_core/tmpls/comps/pwsh.ps1 index 8a52a4f..610522b 100644 --- a/mingling_core/tmpls/comps/pwsh.ps1 +++ b/mingling_core/tmpls/comps/pwsh.ps1 @@ -36,35 +36,41 @@ Register-ArgumentCompleter -Native -CommandName '<<>>' -ScriptBlock { } $completions | ForEach-Object { - $path = $_.Replace('^', '-') + $path = $_ $isDirectory = $path.EndsWith([System.IO.Path]::DirectorySeparatorChar) -or $path.EndsWith('/') $completionType = if ($isDirectory) { 'ProviderContainer' } else { 'ProviderItem' } [System.Management.Automation.CompletionResult]::new($path, $path, $completionType, $path) } } else { - $parsedCompletions = @() + $completionItems = @() + foreach ($item in $completions) { if ($item -match '^([^$]+)\$\((.+)\)$') { - $parsedCompletions += "$($matches[1]):$($matches[2])" - } - else { - $parsedCompletions += $item - } - } - - $simpleCompletions = @() - foreach ($item in $parsedCompletions) { - if ($item -match '^([^:]+):(.+)$') { - $simpleCompletions += $matches[1] + $text = $matches[1] + $description = $matches[2] + $completionItems += @{ + Text = $text + Description = $description + } } else { - $simpleCompletions += $item + $text = $item + $completionItems += @{ + Text = $text + Description = $text + } } } - return $simpleCompletions | ForEach-Object { - [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) + return $completionItems | ForEach-Object { + $resultType = if ($_.Text.StartsWith('-')) { 'ParameterName' } else { 'ParameterValue' } + [System.Management.Automation.CompletionResult]::new( + $_.Text, + $_.Text, + $resultType, + $_.Description + ) } } } -- cgit