Skip to content

Enable fuzzy completions for complete --do-complete? #5467

@faho

Description

@faho

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions