Quick Switcher: give priority to results that include space in search and/or are shorter

Use case or problem

I know the filename including its spaces and I want to open this file. However, there are other similar files which have no space and a much longer filename that are given higher priority, when I start writing more characters in the search, even when I add the unique space.

Setup:

  1. Create files “chapter 0.md”, “chapter0_audio.md”, “chapter0_image.md”

Search issue:

  1. Open Quick Switcher (Ctrl+O) and search “chapter”
    => So far, “chapter 0” is displayed at the top, followed by _image and _audio

  1. Append “0” → search “chapter0”
    => now “chapter0_” files are shown first, but it makes sense

  1. Add a space before 0 → search “chapter 0”
    => same result as without space!

image

So there are two issues:

  • space is ignored from search so you cannot distinguish filenames by adding a space
  • longer filenames may be prioritized, but it’s impossible to add more characters to the shorter filename: at some point you’ve written the whole filename. This means that even an exact match will be appear at the top!

Proposed solution

I’d do the opposite:

  • take space into account in search to prioritize matching results that have the matching space. If there are no such results, it’s okay to ignore it (it just affects priority)
  • give priority to shorter results (that still match search, and that have a decent fuzzy match score compared to other filenames*), since it’s easier to add characters to match longer filenames, than to add characters to match a filename that’s already short (the extreme case being when you write the full filename already and cannot add more).

* For instance, if the fuzzy match percentage of total filename characters becomes greater than the shorter filename match percentage, then you can put the longer filename at the top.

Current workaround (optional)

Oddly enough, typing only “chapter” will bring “chapter 0” to the top, but I have no idea why.

Related feature requests (optional)

I’ve seen other topics requesting to ignore spaces in Quick Switcher: Can the fuzzy match in note search ignore spaces and prioritize note names, not directories?
However, this is about ignoring spaces in the result. My issue is that when the user types a space and there is an actual space match, this increases the priority of results matching the space too.

1 Like