diff options
| author | Niklas Baumstark | 2012-01-25 17:53:48 +0100 |
|---|---|---|
| committer | Niklas Baumstark | 2012-04-10 23:58:07 +0200 |
| commit | 76b981c5a3195eac12054afe2534645cd7610d30 (patch) | |
| tree | 153c921ea9e8dabbb674d3c88962c7f18a58e5d8 | |
| parent | b23ec4bafe188dc584ebd2b674566d429198ae09 (diff) | |
| download | vimium-76b981c5a3195eac12054afe2534645cd7610d30.tar.bz2 | |
fix a bug in the filtering algo that causes caching not to happen
| -rw-r--r-- | lib/completion.js | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/completion.js b/lib/completion.js index 6f5b0f96..68f8d4bf 100644 --- a/lib/completion.js +++ b/lib/completion.js @@ -117,8 +117,8 @@ var completion = (function() { if (!(id in self.filterCache)) self.filterCache[id] = {}; - // find the most specific list of results in the cache - var maxSpecificity = 0; + // find the most narrow list of results in the cache + var optSpecificity = source.length; var specificity; for (key in self.filterCache[id]) { if (!self.filterCache[id].hasOwnProperty(key)) @@ -130,11 +130,15 @@ var completion = (function() { continue; } + // is this a plausible result set to use as a source? + if (query.indexOf(key) < 0) + continue; + // is this cache entry the most specific so far? specificity = self.filterCache[id][key].length; - if (query.indexOf(key) == 0 && specificity > maxSpecificity) { + if (specificity < optSpecificity) { source = self.filterCache[id][key]; - maxSpecificity = specificity; + optSpecificity = specificity; } } |
