Skip to content

Implement fuzzy file finder with keyboard shortcut `f`.

Administrator requested to merge github/fork/olafurpg/olafurpg/fuzzy-modal into main

Created by: olafurpg

Previously, there was no way to interactively search for a file that matches a given fuzzy query. This commit adds a new modal that activates on the keyboard shortcut t and allows the user to quickly open a file that fuzzily matches a given query.

The implementation in this commit is specifically designed to handle large repositories with >100k source files. The fuzzy finder achieves low-latency by:

  1. implementating all the filtering inside the browser on the client-side
  2. using bloom filters to quickly discard buckets of filenames that are guaranteed to not match a given query. This techniqueis used by the Scala language server and documented in this blog post https://scalameta.org/metals/blog/2019/01/22/bloom-filters.html

The downside of this approach:

  1. it can take a while to first download all filenames in the repository, especially for large repos like chromium/chromium
  2. constructing the bloom filters may take a while on very large repositories. It's possible to work around this issue, but it's not implemented in this commit.
  3. the bloom filter algorithmm is sometimes more strict compared to the fuzzy finder in VS Code and IntelliJ. There are techniques to make the fuzzy finder more fuzzy, for example we could make all-lowercase queries case-insensitive. It's also worth consider whether we want scrap the bloom filters altogether and use an entirely different approach, for example by reusing techniques from nvim-telescope.

Demo: low-latency filtering in the chromium/chromium repository (~400k source files). Observe that negative results (0 matches) return instantly, this is a key-feature of the bloom-filter approach.

CleanShot 2021-05-12 at 21 24 48

Demo: exact matches are highlighted differently from incomplete matches making it easier to visually parse the results

CleanShot 2021-05-12 at 22 14 33

Demo: the intermediary page while the fuzzy finder is downloading filenames. For most repos with <20k source files, this step is usually instant. The result is cached for every repoName/commitID pair.

CleanShot 2021-05-12 at 22 41 57

Merge request reports

Loading