quicksilver/Quicksilver — pull request #1162 by skurfer (2012-10-09 15:02:39+00:00)
Title: Getting objects by type

I've added a new method to QSLibrarian that will return an array of objects of a certain type sorted by score. So instead of calling something like

[QSLib scoredArrayForString:nil inSet:[QSLib arrayForType:@"QSBlahType"] mnemonicsOnly:YES];

you can just call

[QSLib scoredArrayForType:@"QSBlahType"];

I've also made a small change to the method that builds type arrays so it will include proxy objects. This means when calling `QSLib arrayForType:` or `QSLib scoredArrayForType:`, relevant proxy objects will be returned along with everything else.

Some real-world examples of where this is useful:

* Text ⇥ Find With… ⇥ Current Website (Safari)
* File ⇥ Copy To… ⇥ Finder Selection

And, in returning results sorted by score, I uncovered (and fixed) some bugs in the scoring algorithm. The first three commits address that.

What it was *supposed* to do: If you search for "xy" and that's never been used before, but "xyz" has been used (or vice versa), increase the score for "xy" a bit based on how often "xyz" has been used.

What it was doing: If the search string was empty, the comparison would *always* think there was a matching prefix for every abbreviation ever used, so the score would be increased a bit for each one. As a result, if something had 4 abbreviations used 10 times each (40 total) and something else had 3 abbreviations used 1000 times each (3000 total), the thing used 40 times would get a higher rank.

So, I told it not to use that technique for empty strings, and additionally defined specific logic for scoring objects when the search string is `nil`. (The total usage for all abbreviations is combined. The actual number of abbreviations has no effect.)