Repository navigation
refactor(suggestions): extract shared did_you_mean helper - #2268
Merged
Merged
Conversation
Both the top-level external dispatcher (`similar_subcommands`) and the `wt step` alias dispatcher (`unknown_step_command_exit`) computed Jaro-Winkler suggestion lists with the same 0.7 threshold, descending sort, and dedupe needs. Pull the scoring loop into a single helper in `commands/mod.rs` and have both sites delegate to it. The helper's docstring pins the 0.7 threshold to clap's internal `did_you_mean` so future maintainers know not to drift. The `alias.rs` site gains harmless dedupe (no shadowing collisions reach that point since shadowed names are filtered upstream). Co-Authored-By: Claude <[email protected]>
worktrunk-bot
approved these changes
Apr 16, 2026
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.
After PR #2266 merged, two sites computed Jaro-Winkler "did you mean" suggestions with the same 0.7 threshold, descending sort, and (mostly) the same dedupe needs:
similar_subcommandsinsrc/commands/external.rs(top-level dispatch) and the inline scoring insideunknown_step_command_exitinsrc/commands/alias.rs(wt stepdispatch). This pulls the scoring loop into adid_you_meanhelper alongsideformat_command_labelincommands/mod.rs, and has both sites delegate to it.The helper's docstring pins the 0.7 threshold to clap's internal
did_you_meanso future maintainers know not to drift. Thealias.rssite gains harmless dedupe — no shadowing collisions reach that point because shadowed names are filtered out before the call.Behavior is unchanged: same threshold, same sort order, same outputs. The five
similar_subcommands_*unit tests inexternal.rsand the twotest_*_alias_did_you_meanintegration tests pass unchanged.