As mentioned by @foonathan on gitter:
I have a string like /u/b and I want to do the path completion to /usr/bin fish does when pressing . But I am writing a script, so I can't press tab. Is there a way to trigger a completion on a string programmatically?
[...]
I've tried complete -C"echo /u" which gives /usr, but complete -C"echo /u/b" doesn't return anything (fish 2.7.1)
This is because complete --do-complete only uses COMPLETION_REQUEST_DEFAULT.
If we changed
|
complete(do_complete_param, &comp, COMPLETION_REQUEST_DEFAULT); |
to
complete(do_complete_param, &comp, COMPLETION_REQUEST_DEFAULT | COMPLETION_REQUEST_FUZZY_MATCH);
It would give fuzzy completions. I believe that would improve the situation in most cases where we currently use it, but if anything is assuming that it's always going to be a prefix (not even a substring) it might break.
Alternatively, we could add another flag that enables fuzzy completions, but it's probably a better default to do them.
As mentioned by @foonathan on gitter:
This is because
complete --do-completeonly usesCOMPLETION_REQUEST_DEFAULT.If we changed
fish-shell/src/builtin_complete.cpp
Line 321 in d7b2576
to
complete(do_complete_param, &comp, COMPLETION_REQUEST_DEFAULT | COMPLETION_REQUEST_FUZZY_MATCH);It would give fuzzy completions. I believe that would improve the situation in most cases where we currently use it, but if anything is assuming that it's always going to be a prefix (not even a substring) it might break.
Alternatively, we could add another flag that enables fuzzy completions, but it's probably a better default to do them.