From b226ddf11348660dc8e9f39dcf7346944082ff67 Mon Sep 17 00:00:00 2001 From: Niklas Baumstark Date: Wed, 25 Jan 2012 00:41:47 +0100 Subject: move query length threshold from UI to logic This enables to set threshold to 0 for tabs (so that tabs are shown before typing). --- lib/completion.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'lib') 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; -- cgit v1.2.3