New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve did-you-mean suggestions by detecting swapped words #4997
base: master
Are you sure you want to change the base?
Improve did-you-mean suggestions by detecting swapped words #4997
Conversation
f696c6e
to
514e5ad
Compare
514e5ad
to
7e56b99
Compare
let input_words = input.split_once('-'); | ||
let candidate_words = candidate.split_once('-'); | ||
match (input_words, candidate_words) { | ||
(Some((input1, input2)), Some((candidate1, candidate2))) => { | ||
input1 == candidate2 && input2 == candidate1 | ||
} | ||
_ => false, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this will only check for one-"word" swaps and only if the word separator is -
(which it really should be) and won't handle typos within those swapped words.
The thing I'm tying to decide if this is too narrow of a niche to include
(and this is the type of discussion I prefer having in Issues before PRs are created)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right ... if you want to I can convert the PR to a draft and we can discuss this in an issue.
Personally I think mixing up the order of words of CLI arguments happens much more often for me than misspelling them. E.g. ripgrep has --type-not
... trying --not-type
instead is a very easy mistake to make but clap currently suggests --no-pre
. I think a small quality of life improvement like this across all clap CLIs would be nice ... sure this logic could be made more elaborate to also handle swaps in arguments consisting of e.g. 3 words but I think 2 word flags are much more common.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to sit on this to give this more thought. I'm trying to weigh out the couple of specific cases this helps with vs where the line is for us supporting these one-off heuristics.
At this point, I would really like to move this discussion to an issue so we decouple the conversation on whether to do it and what we should support from this specific PR (as they can come and go).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened #5029 :)
match (input_words, candidate_words) { | ||
(Some((input1, input2)), Some((candidate1, candidate2))) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't this just if a if let
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it can be ... I guess I personally prefer a match block but I can change it if you prefer if let
.
While using the
deno
CLI (which uses clap) I experienced the following:The option I wanted was
--lock-write
.Resolves #5029.