Skip to content

Commit 57f49ad

Browse files
hhfgy1hhfgy1
andauthored
fix(scoop): handle non-UTF-8 encoding in scoop list output (#1255)
## Description Fix tab completion failure for 'scoop list' on Windows when scoop output contains non-UTF-8 characters. ## Problem On Windows with non-UTF-8 locales (e.g., Chinese Windows using GBK encoding), the `scoop list` command may output text in the system's local encoding, causing the completion to fail silently. ## Solution Use `decode utf-8` to properly handle the output encoding, ensuring the completion works correctly regardless of locale settings. ## Testing Tested on Windows with Chinese locale where scoop outputs GBK-encoded text. Co-authored-by: hhfgy1 <hhf@gspc.com>
1 parent 018fe3c commit 57f49ad

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

custom-completions/scoop/scoop-completions.nu

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,21 +166,17 @@ export extern "scoop" [
166166
################################################################
167167
# scoop list
168168
################################################################
169-
170-
# Lists all installed apps, or the apps matching the supplied query.
171169
export def "scoop list" [
172-
query?: string@scoopInstalledApps # string that will be matched
170+
query?: string@scoopInstalledApps
173171
] {
174-
^scoop list ($query | default "")
175-
| complete
176-
| if $in.exit_code == 0 {
177-
$in.stdout
172+
let result = (^scoop list ($query | default "") | complete)
173+
if $result.exit_code == 0 {
174+
($result.stdout | decode utf-8)
178175
| lines
179176
| skip 4
180177
| parse -r '(?P<name>\S+)\s+(?P<version>\S+)\s+(?P<source>\S+)\s+(?P<updated>\S+\s+\S+)\s+(?P<info>\S+)?'
181178
}
182179
}
183-
184180
################################################################
185181
# scoop uninstall
186182
################################################################

0 commit comments

Comments
 (0)