From 37ef8061309415dfb637b540d523e50992ed607a Mon Sep 17 00:00:00 2001 From: "warp-agent-staging[bot]" <240773466+warp-agent-staging[bot]@users.noreply.github.com> Date: Wed, 19 Aug 2026 15:53:51 +0000 Subject: [PATCH] Fix zsh compadd shim dropping descriptions from _describe's clustered -ld The completions `compadd` shim located the description array with an exact match on `-d`, but `_describe` never passes that flag on its own -- it passes it clustered with other short flags, as `-ld`. The lookup therefore found nothing, no description array was resolved, and every match produced via `_describe` came back with an empty description. `_arguments`-based option descriptions, which do pass `-d` unclustered, were unaffected, which is why some completions had descriptions and others silently did not. Match any flag token of a leading `-`, zero or more letters and a trailing `d` instead of requiring an exact `-d`, and keep using `(I)` rather than `(i)`: `(i)` returns one past the end instead of 0 when nothing matches, which would make the presence test true on every call. The search is also restricted to the leading flags-only prefix the neighboring `-O`/`-A`/`-D` check already uses, so a completion candidate that happens to look like a flag -- a literal `-d` or `-ld`, as `ls` and `find` offer -- is never mistaken for the flag itself. Fixes CORE-3795. --- app/assets/bundled/bootstrap/zsh_body.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/app/assets/bundled/bootstrap/zsh_body.sh b/app/assets/bundled/bootstrap/zsh_body.sh index ef2eaf2391a..75406b2cef3 100644 --- a/app/assets/bundled/bootstrap/zsh_body.sh +++ b/app/assets/bundled/bootstrap/zsh_body.sh @@ -1378,9 +1378,22 @@ esac # do we have a description parameter? # note we don''t use zparseopts here because of combined option parameters # with arguments like -default- confuse it. - if (( $@[(I)-d] )); then # kind of a hack, $+@[(r)-d] doesn''t work because of line noise overload - # next param after -d - __tmp=${@[$[${@[(i)-d]}+1]]} + # + # -d can be passed on its own (e.g. from _arguments) or clustered with other short + # flags (e.g. -ld from _describe). Match any flag token consisting of a leading -, + # zero or more letters, and a trailing d, rather than requiring an exact "-d". Use + # (I), not (i): (i) returns one past the end (not 0) when nothing matches, which + # would make the presence test below true on every call. Restrict the search to the + # same leading flags-only prefix the -O/-A/-D check above uses (everything before the + # first bare "-"/"--"), so a completion candidate that happens to look like a flag + # (a literal "-d"/"-ld" match, e.g. for ls or find) is never mistaken for the flag. + setopt localoptions extendedglob + local -a __flags + __flags=(${@[1,(i)(-|--)]}) + local __d_idx=${__flags[(I)-[a-zA-Z]#d]} + if (( __d_idx )); then + # next param after the flag containing -d + __tmp=${@[$[__d_idx+1]]} # description can be given as an array parameter name, or inline () array if [[ $__tmp == \(* ]]; then eval "__dscr=$__tmp"