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

Alternative matching algorithms (substring, subsequence, etc.) for completions #568

Closed
xiaq opened this Issue Feb 9, 2013 · 6 comments

Comments

Projects
None yet
5 participants
@xiaq
Contributor

xiaq commented Feb 9, 2013

Currently fish only supports prefix matching for completions. Consider these use cases:

  1. $ ls
    very-long-prefix-001 very-long-prefix-002 very-long-prefix-003
    

    Substring matching (or more specifically suffix matching) would be useful in the above case.

$ ls
lorem-ipsum lorem-bar foo-ipsum foo-bar

zsh allows you to type l-i<Tab> and get lorem-ipsum. Like everything in zsh you have to do some mysterious configuration; in this case, you declare - as some type of separator valid in completions.

A more realistic example for the above use cases is package names - say you want to complete libreoffice-base, but both libreoffice and base match a lot of packages. However lib-b would almost certainly match libreoffice-base.

Although I found zsh helpful in case 2., there is still a case it doesn't cover - when components are joined without separators. Matching the string user typed as a subsequence can solve this problem. In the case of separator-delimited components, it can be almost as accurate as zsh's method, except that lib-b also matches libreoffice-l10n-br and liaaaab-aaa-b (the latter is invented, sorry).

@ridiculousfish

This comment has been minimized.

Show comment
Hide comment
@ridiculousfish

ridiculousfish Apr 15, 2013

Member

Related to #528

Member

ridiculousfish commented Apr 15, 2013

Related to #528

@ridiculousfish

This comment has been minimized.

Show comment
Hide comment
@ridiculousfish

ridiculousfish May 25, 2013

Member

Implemented as 908b075

The algorithms we support are (in order of preference):

  1. Exact match - FOOBAR matches FOOBAR
  2. Prefix match - FOO matches FOOBAR
  3. Case insensitive exact match: foobar matches FOOBAR
  4. Case insensitive prefix match - foo matches FOOBAR
  5. Substring match: OOBA matches FOOBAR
  6. Subsequence match: FBR matches FOOBAR

This works for tab completing files and executables, though not yet options.

Member

ridiculousfish commented May 25, 2013

Implemented as 908b075

The algorithms we support are (in order of preference):

  1. Exact match - FOOBAR matches FOOBAR
  2. Prefix match - FOO matches FOOBAR
  3. Case insensitive exact match: foobar matches FOOBAR
  4. Case insensitive prefix match - foo matches FOOBAR
  5. Substring match: OOBA matches FOOBAR
  6. Subsequence match: FBR matches FOOBAR

This works for tab completing files and executables, though not yet options.

This was referenced May 25, 2013

@dag

This comment has been minimized.

Show comment
Hide comment
@dag

dag Jun 5, 2013

Contributor

One little thing I've noticed is that if I try to complete a long option argument when fish has no completions for that command, the double hyphens expand to .oh-my-zsh which I happened to have in the same directory!

Perhaps the fuzzy matching could exclude hyphens.

Contributor

dag commented Jun 5, 2013

One little thing I've noticed is that if I try to complete a long option argument when fish has no completions for that command, the double hyphens expand to .oh-my-zsh which I happened to have in the same directory!

Perhaps the fuzzy matching could exclude hyphens.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Jun 21, 2013

It may be beneficial to try case-insensitive substring/subsequence matching as well.

ghost commented Jun 21, 2013

It may be beneficial to try case-insensitive substring/subsequence matching as well.

ridiculousfish added a commit that referenced this issue Sep 15, 2013

@ridiculousfish

This comment has been minimized.

Show comment
Hide comment
@ridiculousfish

ridiculousfish Sep 15, 2013

Member

95d5e55 addresses dag's issue by disabling fuzzy matching for file completions if the argument begins with a dash.

Member

ridiculousfish commented Sep 15, 2013

95d5e55 addresses dag's issue by disabling fuzzy matching for file completions if the argument begins with a dash.

@krader1961

This comment has been minimized.

Show comment
Hide comment
@krader1961

krader1961 Mar 13, 2017

Contributor

It seems to me this has been addressed so closing.

Contributor

krader1961 commented Mar 13, 2017

It seems to me this has been addressed so closing.

@krader1961 krader1961 closed this Mar 13, 2017

@faho faho removed this from the fish-future milestone Apr 10, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment