fix(zsh): show all matches when subcommand names contain :#666
fix(zsh): show all matches when subcommand names contain :#666zeitlinger wants to merge 2 commits into
:#666Conversation
`_describe` groups matches that share a `\:`-escaped prefix and surfaces only one entry per group. For specs that have several subcommands sharing a colon prefix (e.g. `release:create`, `release:docs-sync`, `release:pr`, `release:update`), the menu only lists `release:create` and silently drops the rest. The same collapse happens when a plain `lint` exists alongside `lint:fix`. Build the display column ourselves from the (insert, description) pair and call `compadd` directly so every match is offered, with descriptions aligned to the longest value. Regression test: feeds a colon-heavy spec through real zsh + zpty and asserts every subcommand appears in the menu output. Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
📝 WalkthroughWalkthroughThis PR refactors zsh completion output formatting: ChangesZsh Completion Format Refactoring
🎯 3 (Moderate) | ⏱️ ~25 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Greptile SummaryFixes a zsh tab-completion bug where
Confidence Score: 4/5The core logic change is correct and the two blocking regressions from the previous review round are resolved; only a stale doc comment remains. The two previously flagged regressions (wrong display label in the lib/src/complete/zsh.rs — doc comment on Important Files Changed
Reviews (2): Last reviewed commit: "fix(zsh): emit three columns (value, des..." | Re-trigger Greptile |
…desc` Greptile flagged that the previous fix used `inserts[i]` (which can be shell-quoted, e.g. `'Alice Bob'`) as the prefix to strip from the `zsh_escape`-d display string. For any value containing a space the strip silently failed and the menu showed `'Alice Bob' -- Alice Bob`. Switch the contract between `complete-word --shell zsh` and the generated template to emit three tab-separated columns — raw value, raw description, shell-quoted insert. The zsh template reads the three fields, builds the formatted display directly from value + description (no `\:`/`\(`/`\[` escaping needed), and feeds the inserts to compadd. Drops the now-unused `zsh_escape` helper. Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
|
Both flagged issues are valid. Switched the contract between This comment was generated by an AI coding assistant. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
lib/src/complete/zsh.rs (1)
19-26: ⚡ Quick winUpdate the function rustdoc to match the new 3-column contract.
The header comment above
render_completion_loopstill describes the old 2-column_describeflow, which now conflicts with this implementation.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lib/src/complete/zsh.rs` around lines 19 - 26, Update the rustdoc for render_completion_loop to describe the current 3-column contract (raw value, description, shell-quoted insert) instead of the old 2-column `_describe` flow: explain that `complete-word --shell zsh` emits three tab-separated columns, that the function builds the formatted display (using `template` and aligned `descs`) and calls `compadd` directly so every match is offered (not collapsed), and note the handling of escaped prefixes like `\:`; reference `render_completion_loop`, `template`, and `compadd` in the comment so readers can locate the related logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@lib/src/complete/zsh.rs`:
- Around line 19-26: Update the rustdoc for render_completion_loop to describe
the current 3-column contract (raw value, description, shell-quoted insert)
instead of the old 2-column `_describe` flow: explain that `complete-word
--shell zsh` emits three tab-separated columns, that the function builds the
formatted display (using `template` and aligned `descs`) and calls `compadd`
directly so every match is offered (not collapsed), and note the handling of
escaped prefixes like `\:`; reference `render_completion_loop`, `template`, and
`compadd` in the comment so readers can locate the related logic.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 0acab893-7a8d-4dfe-8291-864c4643a5b0
⛔ Files ignored due to path filters (4)
lib/src/complete/snapshots/usage__complete__zsh__tests__complete_zsh-2.snapis excluded by!**/*.snaplib/src/complete/snapshots/usage__complete__zsh__tests__complete_zsh-3.snapis excluded by!**/*.snaplib/src/complete/snapshots/usage__complete__zsh__tests__complete_zsh.snapis excluded by!**/*.snaplib/src/complete/snapshots/usage__complete__zsh__tests__complete_zsh_init.snapis excluded by!**/*.snap
📒 Files selected for processing (4)
cli/src/cli/complete_word.rscli/tests/complete_word.rscli/tests/shell_completions_integration.rslib/src/complete/zsh.rs
Summary
_describegroups matches that share a\:-escaped prefix and surfaces only one entry per group. With several subcommands sharing a colon prefix (e.g.release:create,release:docs-sync,release:pr,release:update) the menu only listsrelease:createand silently drops the rest. The same collapse happens when a plainlintexists alongsidelint:fix.Repro
Generate zsh completion, tab
testcli <TAB>— before this PR, onlyrelease:createandlintappear. After: all six show.Discovered via jdx/mise where users have tasks named
release:create,release:docs-sync,release:pr,release:update— most of them disappeared from completion.Fix
Build the display column ourselves from the
(insert, description)pair and callcompadddirectly so every match is offered, with descriptions padded to the longest value for column alignment.Test plan
cargo testsuite passes locally (cargo test --release)lib/src/complete/snapshots/...)test_zsh_completion_includes_all_colon_subcommandsfeeds a colon-heavy spec through real zsh + zpty and asserts every subcommand appears in the menuThis PR was authored with assistance from an AI coding agent.
Summary by CodeRabbit
Release Notes