1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-07 02:15:45 +01:00

Sort anchored matches before non-anchored matches when doing non-anchored matching.

--HG--
branch : key-processing
This commit is contained in:
Kris Maglione
2011-01-26 17:21:05 -05:00
parent f44ba86101
commit f4cc496dbe

View File

@@ -483,8 +483,13 @@ var CompletionContext = Class("CompletionContext", {
filtered = filtered.slice(0, this.maxItems);
// Sorting
if (this.sortResults && this.compare)
if (this.sortResults && this.compare) {
filtered.sort(this.compare);
if (!this.anchored) {
let filter = this.filter;
filtered.sort(function (a, b) (b.text.indexOf(filter) == 0) - (a.text.indexOf(filter) == 0));
}
}
return this.cache.filtered = filtered;
}