nixprime / cpsm

A CtrlP matcher, specialized for paths.
Apache License 2.0
202 stars 19 forks source link

Score contiguous matches higher #18

Closed eapache closed 8 years ago

eapache commented 8 years ago

Here's an interesting case I came across where cpsm's scoring algorithm doesn't really do the right thing, but I think it should be easy enough to fix:

I have g:cpsm_query_inverting_delimiter = ' '. There is a file foo/bar/graph/order.rb. When I search cpsm with order gra that file is not the first match; the first match is tmp/VZOCh7GJ4RUldAJOTIMRwSm0k8DmFMRexROl... because if you'll note all of the necessary characters do appear in the correct order in that random string. The simple fix is to remove the tmp directory from the ctrl-p search path but I think it also reveals that cpsm should be prioritizing matches somewhat based on contiguity of the match. The desired file matched the given query in two large chunks, whereas the tmp file matched 8 individual characters.

The scorer already contains parts which is the number of path components... generalizing this to the number of contiguous match groups regardless of path componentization seems like a simple fix.

nixprime commented 8 years ago

A query-inverting delimiter doesn't imply a path separator, so your query is being interpreted as graorder; order gr/ should give you much better results.

eapache commented 8 years ago

Yes, I figured that out but I think my original point still stands. graorder matched in two contiguous chunks should score better than another match across eight discontinuous letters.

eapache commented 8 years ago

Experimental branch has been working very well for me. I don't know what else you plan to do before merging it to master, but I'm gonna close this regardless.