From 685f461e181a22b6112ab2ee3ed9caba46998c4b Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Thu, 2 Jul 2026 16:42:03 +0800 Subject: fix(run): force $sorted to array to avoid char indexing on single tool When only one tool exists, the sorted pipeline returns a single string instead of an array. Indexing it (e.g., $sorted[0]) then returns a character rather than the full tool name, causing errors like "Method invocation failed because [System.Char] does not contain a method named 'ToLower'". Wrapping the pipeline in @() ensures $sorted is always an array, fixing both the list display and number-based selection. --- run.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run.ps1 b/run.ps1 index 3a7dc09..af8effe 100644 --- a/run.ps1 +++ b/run.ps1 @@ -73,7 +73,7 @@ if (Test-Path ".run/src/bin/*.zig") { } if ($args.Count -eq 0) { - $sorted = $tools.Keys | Sort-Object @{Expression={if ($tools[$_].Type -eq 'ps1') {0} else {1}}}, {$_} + $sorted = @($tools.Keys | Sort-Object @{Expression={if ($tools[$_].Type -eq 'ps1') {0} else {1}}}, {$_}) $total = $sorted.Count $num_w = $total.ToString().Length @@ -120,7 +120,7 @@ if ($args.Count -eq 0) { $target_name = $args[0] if ($target_name -match '^\d+$') { - $sorted = $tools.Keys | Sort-Object @{Expression={if ($tools[$_].Type -eq 'ps1') {0} else {1}}}, {$_} + $sorted = @($tools.Keys | Sort-Object @{Expression={if ($tools[$_].Type -eq 'ps1') {0} else {1}}}, {$_}) $idx = [int]$target_name - 1 if ($idx -ge 0 -and $idx -lt $sorted.Count) { $target_name = $sorted[$idx] -- cgit