Skip to content

Completion algorithm: try prefix, fallback to fuzzy if, and only if, prefix gives no results #11211

Open

Description

@k0ral

Related problem

The completions.algorithm option currently supports 2 values: fuzzy and prefix.

What about supporting a 3rd mode for {what the title says} ?

Describe the solution you'd like

  • completions.algorithm can be set to prefix_fallback_fuzzy (yeah, naming things is hard...)
  • when set to that mode, auto-completion works like this:
    • first, look for prefix matches ; if there are some, act as if completions.algorithm were set to prefix
    • if there are no prefix matches, act as if completions.algorithm were set to fuzzy

Describe alternatives you've considered

I'm not aware of any trick to emulate that behavior with current nushell.

Additional context and details

No response

Activity

  1. added
    category:enhancement
    status:needs-triage
    on Dec 2, 2023
  2. fdncred commented on Dec 2, 2023

    @fdncred
    Contributor

    Hmmm, I'd have to try it out to see if it fits. Seems like it would be ok, but I just don't know. I could see them named prefix, fuzzy, or fallback and fallback means its set to prefix, falling back to fuzzy.

  3. added
    A:completions
    and removed
    status:needs-triage
    on Dec 2, 2023
  4. curldivergence commented on Mar 25, 2024

    @curldivergence

    Hi! Sorry for hijacking the thread (I found it by keyword "fuzzy"), but it didn't seem worth it to create a new issue.
    So I have a question: what exactly is the difference between "prefix" and "fuzzy"? E.g. in fish I can type any substring, e.g. argo, and press Arrow-Up, and it will start scrolling over past commands that contained it (e.g. cargo run, which cargo etc.). But unfortunately, I can't get the same behavior in nu whatever I do: at first I expected that this fuzzy option will enable this behavior, but it did not. Then I gave up and enabled fish completer as an external one, but it didn't work either :( Thanks!

  5. fdncred commented on Mar 25, 2024

    @fdncred
    Contributor

    @curldivergence I'm not sure it works like that right now. I quickly looked into reedline and found this section which seems to indicate History Navigation with a Fuzzy algorithm isn't implemented yet.
    https://github.com/nushell/reedline/blob/6957b5ab7b98c3f090131e9388c18c1826812314/src/history/base.rs#L7-L16

    We may accept a PR to implement such a feature. I don't remember anyone asking for it though, before you.

  6. curldivergence commented on Mar 25, 2024

    @curldivergence

    @fdncred Thanks a lot for looking into this! A couple more questions though, if you don't mind :)

    • I can see there is SubstringSearch enum variant there, so my example with argo would still be expected to work, wouldn't it?
    • could you elaborate on the difference between this SubstringSearch and fuzzy search, please? The fuzzy one would be expected to find other history items within a given Levenshtein distance, or I understand it wrong?
    • and generally speaking, this behavior (scrolling through history items after typing something in the shell and pressing Arrow-Up) logically belongs to history or to completions?
      Thank you!
  7. fdncred commented on Mar 25, 2024

    @fdncred
    Contributor

    I'm guessing all of this is a reedline thing vs a nushell thing but could be wrong.

    1. I think so? i haven't messed with this much.
    2. substring maybe should work like argo. fuzzy would work like typing gco and matching git checkout
    3. i think what you're looking for is history vs completions because you don't want to scroll through completions, you want to see the next history result that matches what you type.
  8. curldivergence commented on Mar 25, 2024

    @curldivergence

    @fdncred Got it, thanks a lot for you help!

  9. tobiasBora commented on Dec 18, 2025

    @tobiasBora

    Out of curiousity, why don't we allow the user to write custom completion algorithm?

  10. unnamedname commented on Apr 28, 2026

    @unnamedname

    Indeed, another nice thing to have from Fish.

    Users’ expectations regarding completion for different parts of the command line are rarely one-size-fits-all. For me, the problem with the current completions.algorithm is that fuzzy often results in redundant command/argument suggestions, whilst prefix, conversely, leads to no results for (fallback) path completions. Furthermore, for up-arrow key completion (from command history), Fish’s substring matching is more intuitive (than Nushell’s prefix-only approach).

  11. flying-sheep commented on Jul 27, 2026

    @flying-sheep
    Contributor

    Fuzzy can be quite confusing, but I guess that’s only when things are broken.

    E.g. I use the fish completer for git but failed to install fish on a system. I also have

    export extern "yarn plugin import from sources" [...] {...}

    So completing git with “fuzzy” gave me yarn plugin import from sources lol.

    But maybe that just means that fuzzy isn’t for me as it kinda always gives something.

  12. added this to the v0.115.0 milestone on Aug 2, 2026
  13. added a commit that references this issue on Aug 2, 2026
    1385580
  14. j-chmielewski commented on Aug 12, 2026

    @j-chmielewski

    @fdncred I think merging #18761 closed this issue by mistake - it doesn't seem to me that it implements the "prefix-to-fuzzy" completion algorithm.

    I would be interested in implementing this behavior. Please let me know if you think this would be a welcome contribution and perhaps reopen the issue?

  15. fdncred commented on Aug 12, 2026

    @fdncred
    Contributor

    @j-chmielewski ya, have at it?
    @philocalyst thoughts on the comment just above? Was this issue closed by mistake?

  16. removed this from the v0.115.0 milestone on Aug 17, 2026
  17. kronberger-droid commented on Nov 14, 2026

    @kronberger-droid
    Contributor

    Status on 0.117: algorithm accepts prefix, fuzzy and substring.
    The fallback is open as #18965.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:completionscategory:enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions