Usagi
Usagi

Reputation: 2946

What is the number prepended to the Sublime Text "Goto Anything" search?

Whenever I use the Goto Anything search in Sublime Text and start typing to search the files in my current project I get a whole bunch of results based on Sublime Text's fuzzy-search algorithm, each prepended with a number.

I assume this is some sort of score for the search "strength" but I just wanted confirm this. What is this number based on?

Upvotes: 1

Views: 49

Answers (1)

Enteleform
Enteleform

Reputation: 3833

It seems like the numbers are indeed representative of match strength, as you assumed.

I noticed an odd effect when testing your hypothesis, and then proceeded to create the dummy files CustomCompletions.CustomCompletions & CustomCompletions ( a file with no extension ) for further comparison.


Here are the results:

Demo


As you can see,

  1. CustomCompletions has the highest ranking with 1524
  2. CustomCompletions.py & CustomCompletions.todo share a rank of 1507
  3. CustomCompletions.CustomCompletions & CustomCompletions.sublime-settings share a rank of 1490
  4. All of the remaining files, which contain additional text in the base name, continue to receive lower rankings.

What I found odd was that the 2nd & 3rd groups had different rankings, despite sharing a base file name that exactly matches the query.

I figured that it might be due to the number of characters in the file extension, so I tested that assumption by creating the following files:

CustomCompletions.a
CustomCompletions.ab
CustomCompletions.abc
CustomCompletions.abcd
CustomCompletions.abcde
CustomCompletions.abcdef
CustomCompletions.abcdefg
CustomCompletions.abcdefgh
CustomCompletions.abcdefghi
CustomCompletions.abcdefghij

CustomCompletions.1
CustomCompletions.12
CustomCompletions.123
CustomCompletions.1234
CustomCompletions.12345
CustomCompletions.123456
CustomCompletions.1234567
CustomCompletions.12345678
CustomCompletions.123456789
CustomCompletions.1234567890

But it turns out they all ranked at 1507, the same ranking as the 2nd group.

Because of that outcome, I am still unsure what criteria affects the ranking of files which share a base name that is an exact match for the Goto Anything query, but have differing file extensions.

Upvotes: 2

Related Questions