ukyouz / SublimeText-SimpleFuzzy

Fuzzy search line-based jump for the current file and project files.
MIT License
5 stars 0 forks source link

Non-exact matching has priority over exact matching? #5

Open vinoff opened 2 years ago

vinoff commented 2 years ago

Here is the thing I am seeing:

I am searching for "rsi". I have text such as "momentum_rsi" and "bla bla RSI" in a file. I also have something like "return str(blabla), blabla1, blabla2, blabla_inc". Using SimpleFuzzy to search for "rsi", returns me the following:

1st match: return str(blabla), blabla1, blabla2, blabla_inc

2nd match; momentum_rsi();

3rd/4th/5th/etc match: match matches like the first

nth match: momentum RSI

Any idea what is happening?

ukyouz commented 2 years ago

The issue may because of that the built-in Sublime Text fuzzy algorithm is good for searching filenames and symbols, and bad for arbitrary source code lines. That is, the algorithm does not score more for those exact matched characters.

Refer to the article Reverse Engineering Sublime Text’s Fuzzy Match.

The current implantation for this plugin is quite simple and relies on Sublime Text built-in fuzzy algorithm. To achieve the ranking you expected requires further effort and different searching engine.

vinoff commented 2 years ago

Would that explain the default "Find in Files" (ctrl+shift+f) finding it correctly?

ukyouz commented 2 years ago

I guess sublime use different weight of factors to calculate the final score for "Find in Files" action. For example, exact matching get much higher score of similarity, etc.

vinoff commented 2 years ago

I see. So, you use the same fuzzy algorithm but with different weights..? Is a fix to this issue something that could be easily done or not really?