zedapp / zed

Rethinking code editing.
http://zedapp.org
MIT License
2.22k stars 162 forks source link

Wrong text matching algorithm for files #173

Closed zefhemel closed 10 years ago

zefhemel commented 10 years ago

From a Hacker News comment:

IMO you're using the wrong text matching algorithm for file search. This is pretty critical, considering it's the main interface for opening files. Zed seems to search for simple text substrings only, whereas both Sublime Text 2 and Xcode look for the longest common subsequence. This is huge, for me at least; in Xcode or ST2 I can type the first few letters of one of my files, followed by a few more letters from different words in it, followed by ".cpp" and it finds the file. Zed (as is) is completely unusable to me, because my project folder contains many similarly named files (.h, .cpp) as well as a ton of other source files from external libraries/modules with similar sub-words with what I'm searching for which for some reason always show up first and saturate the search results. With Zed there's no way to narrow down to what I'm looking for besides typing in the full name of the file. With ST2 or Xcode this is not a problem due to LCS.

and

fwiw the search is called fuzzy matching

ghost commented 10 years ago

I think I agree, but I'm not entirely certain I understand. I've had a couple cases where I typed an exact filename and zed showed an inexact match prior to the exact match. But usually I don't experience that much redundancy in my project's file names, so I usually just type 3-4 letters of the file name and get the one I want right up front.

zefhemel commented 10 years ago

More from HN related to this:

On a related note, Komodo Edit/IDE has a great feature in their fuzzy matcher. In ST3 for example, a space is basically treated like the regex /.*/ This means that if you type something you can only the filter results on the RHS of your input do far. Consider: Models/player.js Controllers/player.js Views/player.js If I type "play" then I need to hit home to filter further. In Komodo, space is treated as a logical AND, which you can use to more effectively search the above. I've not tried Zed yet, but if it can handle this case then that's a plus point from me.

zefhemel commented 10 years ago

And more:

Another interesting algorithm for fuzzy searching is this one: http://www.catalysoft.com/articles/StrikeAMatch.html It essentially compares the number of matching two letter pairs in strings. I used it in a C# app that did a fuzzy instant search as the user typed more letters in. On a dataset of about six thousand names it performed really well, but it was a pretty simple app. I also used a javascript version on the same list to see how it performed on an X120e netbook, and again, it was instantaneous. No idea how the performance would compare to the methods for common substring. I like the pairs matching because I can screw up letter positioning and accidentally type a letter or two that doesn't exist in the string, but still get back strongly matching results and usually find what I want. I used it because we had a huge issue at work with people brutalizing names they entered into our employee database. Here's an implementation I wrote in javascript: https://gist.github.com/doorhammer/3016ecaac5313a87804b I never used it in production, and it's not optimized really at all, but it shows how straight forward a typical version can be.

And here's an explanation with some code examples: http://www.quora.com/Algorithms/How-is-the-fuzzy-search-algorithm-in-Sublime-Text-designed?share=1

cesarmiquel commented 10 years ago

+1 to this feature. I've been using zed for a couple of days and since the idea is (AFAIU) that you find your files with CTRL-E it should be very good at this. The current algorithm is limited so it would be great to be able to find files as is done in Sublime 2/3. Maybe you should give it a go and you'll quickly understand how powerful it is.