-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Implement completion NoMatching #1833
base: main
Are you sure you want to change the base?
Conversation
c00a315
to
217ca52
Compare
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.
Thanks @raphaelvigee.
Could you provide a small test program that uses the new directive so I can figure out how the user would use this?
|
||
__%[1]s_debug "nospace: $nospace, nofiles: $nofiles" | ||
__%[1]s_debug "nospace: $nospace, nofiles: $nofiles, nomatching: $nomatching" | ||
|
||
# If we want to prevent a space, or if file completion is NOT disabled, | ||
# we need to count the number of valid completions. | ||
# To do so, we will filter on prefix as the completions we have received | ||
# may not already be filtered so as to allow fish to match on different | ||
# criteria than the prefix. | ||
if test $nospace -ne 0; or test $nofiles -eq 0 |
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.
This is a special case which the comment may not have made very clear.
Let's take file completion. We only want to trigger file completion if there are no other completions available (from the point of view of the user). This is not normally what fish does, but it is how the other shells behave so we decided to standardize on that.
However, if the program does not filter on prefix (to allow fuzzy matching), it will always return some completions and we will not be able to know if fish will match any of them or not; so, we would not know if there are no real completions and couldn't tell if we should trigger file completion. Therefore, in this case, we turn off fuzzy matching and explicitly match on prefix; if there are no completions left, we know to turn on file completion.
A similar scenario applies to the nospace
directive. You can refer to #1249 for details.
This means that in this case, we cannot do fuzzy completion, or it would break the request from the program to do file completion and/or nospace completion.
I don't know if that was clear, so don't hesitate to ask for clarification.
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.
Hum I see, what do you suggest changing the logic to in that case ?
217ca52
to
832f8c8
Compare
832f8c8
to
fbd01ec
Compare
To be honest, I still don't understand what the PR is trying to achieve. Fuzzy matching works for me on both zsh and fish right now. Could it be that fuzzy matching does not work for you for fish because FileCompletion or NoSpace are requested? Which is a current limitation as explained in #1833 (comment) |
The Cobra project currently lacks enough contributors to adequately respond to all PRs. This bot triages issues and PRs according to the following rules:
|
@marckhouzam Sorry I missed that, i m pretty sure zsh does prefix matching, which is what this PR is trying to change to fuzzy matching, but i ll double check |
Re #1828
Was only able to get it to work on zsh & fish. bash not supported, was not able to test powershell