Repository navigation
fix(completion): skip prefix filtering to enable shell substring matching - #1471
Merged
Merged
Conversation
Return all branch candidates to the shell instead of pre-filtering by prefix. This lets fish and zsh apply their native substring/fuzzy matching — e.g. `wt switch auth<TAB>` now surfaces `feature/user-auth` in fish. The >100 remote-only branch exclusion from #1442 is preserved to avoid overwhelming shells with thousands of candidates. Closes #1468 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Owner
|
thanks @benjaminbauer ! |
|
thank you @max-sixty for the swift solution and for running an awesome project! |
max-sixty
pushed a commit
that referenced
this pull request
Mar 13, 2026
…hing (#1471) ## Summary - Stop prefix-filtering branch candidates in `BranchCompleter::complete()` — return all surviving candidates (after the >100 remote exclusion from #1442) and let the shell apply its own matching - Enables fish substring matching (`auth<TAB>` → `feature/user-auth`) and zsh fuzzy matching for `wt switch` completions - Adds dedicated test for the substring-matching use case from #1468 Closes #1468 ## Test plan - [x] All 46 completion tests pass (including updated `test_complete_with_partial_prefix_returns_all_branches` and new `test_complete_switch_returns_candidates_for_substring_matching`) - [x] Unit tests pass - [x] Lints pass - [ ] CI green across platforms 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: worktrunk-bot <[email protected]> Co-authored-by: Claude Opus 4.6 <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Mar 19, 2026
Bash's programmable completion (`complete -F`) does not filter `COMPREPLY` by 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 the `feature/*` 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 in `maybe_handle_env_completion()` after `engine::complete()` returns, so it handles all argument forms correctly (`--base=m` → `--base=main`, `-b m` → `main`, etc.). Adds `test_completion_cross_shell_filtering_contract` which 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 > _This was written by Claude Code on behalf of @max-sixty_ --------- Co-authored-by: worktrunk-bot <[email protected]> Co-authored-by: Claude <[email protected]> Co-authored-by: Maximilian Roos <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Mar 19, 2026
…istency HookCommandCompleter was pre-filtering completions by prefix, preventing fish/zsh users from doing substring matching on hook command names. BranchCompleter was already fixed for this (#1471), but HookCommandCompleter was missed. The bash-specific prefix filter in maybe_handle_env_completion() already handles bash correctly. Also inlines complete_hook_commands() (single call site) and fixes stale docstring (wt step → wt hook). Co-Authored-By: Claude <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Mar 19, 2026
…istency (#1627) `HookCommandCompleter::complete()` was pre-filtering completions by prefix, preventing fish/zsh users from doing substring matching on hook command names. `BranchCompleter` was already fixed for this in #1471, but `HookCommandCompleter` was missed. The bash-specific prefix filter in `maybe_handle_env_completion()` already handles bash correctly — this just removes the redundant (and harmful) filter from the completer itself, matching `BranchCompleter`'s approach. Also inlines `complete_hook_commands()` (single call site) and fixes a stale docstring (`wt step` → `wt hook`). > _This was written by Claude Code on behalf of @max-sixty_ --------- Co-authored-by: worktrunk-bot <[email protected]> Co-authored-by: Claude <[email protected]>
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.
Summary
BranchCompleter::complete()— return all surviving candidates (after the >100 remote exclusion from fix(completion): exclude remote branches when total exceeds 100 #1442) and let the shell apply its own matchingauth<TAB>→feature/user-auth) and zsh fuzzy matching forwt switchcompletionsswitch#1468Closes #1468
Test plan
test_complete_with_partial_prefix_returns_all_branchesand newtest_complete_switch_returns_candidates_for_substring_matching)🤖 Generated with Claude Code