diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/completion.js | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/completion.js b/lib/completion.js index 338ccbbb..35b1d132 100644 --- a/lib/completion.js +++ b/lib/completion.js @@ -83,9 +83,9 @@ var completion = (function() { /** Trims the size of the regex cache to the configured size using a FIFO algorithm. */ self.cleanMatcherCache = function() { // remove old matchers - queries = Object.keys(self.matcherCache); - for (var i = 0; i < queries.length - self.matcherCacheSize; ++i) + Object.keys(self.matcherCache).forEach(function(query) { delete self.matcherCache(queries[i]); + }); } /** Returns a regex that matches a string using a fuzzy :query. Example: The :query "abc" would result @@ -95,6 +95,7 @@ var completion = (function() { query = self.normalize(query); if (!(query in self.matcherCache)) { // build up a regex for fuzzy matching + // TODO use an array and .join here var regex = '^'; for (var i = 0; i < query.length; ++i) regex += '([^' + query[i] + ']*)(' + query[i] + ')'; @@ -108,8 +109,6 @@ var completion = (function() { * results of the last filtering are used as a starting point, instead of :source. */ self.filter = function(query, source, getValue, id) { - var filtered = []; - if (!(id in self.filterCache)) self.filterCache[id] = {}; @@ -318,6 +317,8 @@ var completion = (function() { this.refresh = function() { }; + // TODO make this shorter and use a more functional way to do it + /** Checks if the input is a special command and if yes, add according suggestions to the given array */ this.addCommandSuggestions = function(query, suggestions) { // check if the input is a special command @@ -340,6 +341,7 @@ var completion = (function() { suggestions.push({ render: createConstantFunction('<em>' + desc + '</em> ' + term), action: createActionOpenUrl(utils.createFullUrl(url)), + relevancy: -2, // this will appear even before the URL/search suggestion }); } } |
