Skip to content

Commit 9c0c61e

Browse files
committed
fix: fish empty partial quoting + bash standalone enum fallback
Address BugBot round 5 findings: 1. Fish: Quote $current so empty partial (TAB after space) is passed as "" instead of being silently dropped by fish's empty-list expansion, which would misinterpret the last preceding word. 2. Bash: Add standalone fallback for enum value lookup. For standalone commands like 'sentry api --method', COMP_WORDS[2] is a flag not a subcommand, so the cmd_subcmd_flag_values lookup fails. Now falls back to cmd_flag_values.
1 parent 6cd74f8 commit 9c0c61e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/lib/completions.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,12 @@ export function generateBashCompletion(binaryName: string): string {
301301
local val_var="$(__${binaryName}_varname "\${cmd}")_$(__${binaryName}_varname "\${subcmd}")_$(__${binaryName}_varname "\${prev#--}")_values"
302302
if [[ -n "\${!val_var+x}" ]]; then
303303
COMPREPLY=($(compgen -W "\${!val_var}" -- "\${cur}"))
304+
else
305+
# Fallback for standalone commands (subcmd is a flag, not a subcommand)
306+
local standalone_val_var="$(__${binaryName}_varname "\${cmd}")_$(__${binaryName}_varname "\${prev#--}")_values"
307+
if [[ -n "\${!standalone_val_var+x}" ]]; then
308+
COMPREPLY=($(compgen -W "\${!standalone_val_var}" -- "\${cur}"))
309+
fi
304310
fi`
305311
: "";
306312

@@ -520,7 +526,9 @@ function __${binaryName}_complete_dynamic
520526
# commandline -ct: the current token being completed (the partial)
521527
set -l preceding (commandline -opc)
522528
set -l current (commandline -ct)
523-
${binaryName} __complete $preceding[2..] $current 2>/dev/null | while read -l line
529+
# Quote $current so an empty partial (TAB after space) is passed as ""
530+
# instead of being silently dropped by fish's empty-list expansion.
531+
${binaryName} __complete $preceding[2..] "$current" 2>/dev/null | while read -l line
524532
echo $line
525533
end
526534
end

0 commit comments

Comments
 (0)