fix(autocomplete): rejoin trailing colon command tokens - #80
fix(autocomplete): rejoin trailing colon command tokens#80sylvesterkaczmarek wants to merge 2 commits into
Conversation
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 08c2e73de1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for i+1 < len(args) && (args[i+1] == ":" || strings.HasSuffix(current, ":")) { | ||
| if args[i+1] == ":" { | ||
| current += ":" | ||
| i++ | ||
| // Check if there's a following element after the ":" | ||
| if i+1 < len(args) && args[i+1] != ":" { | ||
| current += args[i+1] | ||
| i++ | ||
| } | ||
| } else { | ||
| break | ||
| } | ||
| current += args[i+1] | ||
| i++ |
There was a problem hiding this comment.
Preserve spaces after colon-ending arguments
When a completed argument legitimately ends in :, this loop now concatenates the following whitespace-delimited argument as though it were part of the same token. For example, the Bash path in internal/autocomplete/shellscripts/bash_autocomplete.bash:9 passes openai beta:assistants create --instructions Prefix: --mo<Tab> as separate arguments, but reconstruction changes the last two to Prefix:--mo; GetCompletions therefore no longer recognizes --mo as a flag prefix and omits --model. Avoid joining merely because current ends in a colon when the boundary represents a real space (the empty-current case after Prefix: is affected similarly).
Useful? React with 👍 / 👎.
|
Security review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
Summary
Make completion argument reconstruction honor the trailing-colon case that the helper already documents.
Fixes #79.
Problem
Shell completion can split colon-named CLI commands at different word-boundary shapes.
rebuildColonSeparatedArgsis intended to normalize those shapes before command lookup.Its comment explicitly says to keep joining when either:
":"; or":".The second condition currently cannot do useful work. The loop admits the trailing-colon case, but the inner branch immediately executes
breakunless the next token itself equals":".So:
currently returns:
instead of:
Root cause
The loop condition and loop body encode different rules:
When only
strings.HasSuffix(current, ":")is true, execution enters the loop and immediately leaves it without joining the next token.Fix
The reconstruction rule can be expressed directly: while either boundary condition holds, append the next token to the accumulated token and advance.
That handles all of these consistently:
Ordinary arguments without colon boundaries remain untouched.
Regression coverage
Added a focused table-driven test covering:
The trailing-colon case fails on current upstream
mainand passes with this change.Validation
The branch is based directly on upstream
mainatd082a010f7c6cacf407d8a1581446a7857f9f1bband is not behind it.Production code is reduced by nine net lines because the contradictory nested branch is replaced with the direct reconstruction rule. Regression coverage lives in a separate focused test file.
Full repository validation is left to the repository's GitHub Actions checks.
Risk
Low. The change is confined to the internal argv reconstruction used by shell completion. It only joins the next token in cases where the helper's existing loop condition already identifies a colon boundary, and leaves ordinary argument sequences unchanged.