diff options
Diffstat (limited to 'lib/completion.js')
| -rw-r--r-- | lib/completion.js | 13 | 
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/completion.js b/lib/completion.js index d36dc2e5..b5793437 100644 --- a/lib/completion.js +++ b/lib/completion.js @@ -449,9 +449,13 @@ var completion = (function() {    }    /** A meta-completer that delegates queries and merges and sorts the results of a collection of other -   * completer instances. */ -  var MergingCompleter = function(sources) { +   * completer instances given in :sources. The optional argument :queryThreshold determines how long a +   * query has to be to trigger a refresh. */ +  var MergingCompleter = function(sources, queryThreshold) { +    if (queryThreshold === undefined) +      queryThreshold = 1; // default      this.sources = sources; +    this.queryThreshold = queryThreshold;    }    MergingCompleter.prototype = {      refresh: function() { @@ -459,6 +463,11 @@ var completion = (function() {      },      filter: function(query, callback) { +      if (query.length < this.queryThreshold) { +        callback([]); +        return; +      } +        var all = [];        var counter = this.sources.length;  | 
