lewang / flx

Fuzzy matching for Emacs ... a la Sublime Text.
GNU General Public License v3.0
518 stars 37 forks source link

prefer shorter matches #86

Closed fommil closed 8 years ago

fommil commented 8 years ago

I've been noticing that flx prefers longer names over shorter names, even if the shorter name is an exact match:

(flx-score "fake.scala" "fake")  ;; (296 0 1 2 3)
(flx-score "FakeSpec.scala" "fake") ;; (296 0 1 2 3)

for some reason the longer one shows up first in my projectile-find-file which is using flx-ido.

Is there any way you could order things by score and then length (shortest first), that'd be ace.

lewang commented 8 years ago

It's not the length of the string that the algorithm cares about, but index of the matching word that occurs in the string. Always sorting can be expensive for large collections and you can get the result you want by simply continuing to type the next character - ".".

Generally speaking, when working with flx, if the order isn't what you expected, you can just keep typing a few more characters to get it right.

On Thu, Feb 25, 2016 at 4:02 PM, Sam Halliday notifications@github.com wrote:

I've been noticing that flx prefers longer names over shorter names, even if the shorter name is an exact match:

(flx-score "fake.scala" "fake") ;; (296 0 1 2 3) (flx-score "FakeSpec.scala" "fake") ;; (296 0 1 2 3)

and for some reason the longer one shows up first in my projectile-find-file which is using flx-ido.

Is there any way you could order things by score and then length (shortest first), that'd be ace.

— Reply to this email directly or view it on GitHub https://github.com/lewang/flx/issues/86.

Le

fommil commented 8 years ago

ok, I can live with that. Thanks for the response.