Repository navigation
fix: filter completions by prefix for bash shell - #1622
Merged
Merged
Conversation
Bash's programmable completion (-F) does not filter COMPREPLY by prefix — whatever the completion function puts in the array is displayed as-is. The binary was returning all branch candidates for every shell, expecting each shell to apply its own matching. This works for fish (substring) and zsh (fuzzy), but bash users see all branches regardless of what they've typed. Now the binary filters completions by prefix when the requesting shell is bash (COMPLETE=bash), while still returning all candidates for fish/zsh. Closes #1621 Co-Authored-By: Claude <[email protected]>
This was referenced Mar 19, 2026
Adds test_completion_cross_shell_filtering_contract which verifies the same branches with the same typed prefix produce different results per shell: - bash: only prefix matches (binary filters) - fish/zsh: all candidates (shell does its own matching) This captures the tension between #1468 and #1621 in a single test. Also fixes a stale comment in test_complete_base_flag_all_formats. Co-Authored-By: Claude <[email protected]>
worktrunk-bot
added a commit
that referenced
this pull request
Mar 19, 2026
The review bot consistently performs full code analysis (10-18 minutes of CI compute) on self-authored PRs, only to stay silent because it cannot approve its own work. Observed 6 times across PRs #1610, #1613, #1614, #1619, #1622, #1623. Add early-exit guidance in step 1 to skip steps 2-4 for self-authored PRs. The bot still monitors CI and resolves threads, but skips the redundant code review that always produces zero visible output. Co-Authored-By: Claude Opus 4.6 <[email protected]>
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bash's programmable completion (
complete -F) does not filterCOMPREPLYby prefix — whatever the completion function puts in the array is displayed as-is. After #1471 removed prefix filtering to enable fish/zsh substring matching, bash users saw all branches regardless of what they'd typed. For users with many branches (the reporter had 80),wt switch feat<TAB>prompts "Display all 80 possibilities?" instead of showing only thefeature/*branches.When the requesting shell is bash (
COMPLETE=bash), filter completion candidates by prefix before outputting them. Fish and zsh still receive all candidates so they can apply their native substring/fuzzy matching. The filtering runs inmaybe_handle_env_completion()afterengine::complete()returns, so it handles all argument forms correctly (--base=m→--base=main,-b m→main, etc.).Adds
test_completion_cross_shell_filtering_contractwhich verifies the same branches with the same typed prefix produce different results per shell — the test that would have caught the #1471 regression.Thanks to @altruic for reporting in #1621.
Closes #1621