aboutsummaryrefslogtreecommitdiffstats
path: root/lib/completion.js
diff options
context:
space:
mode:
authorNiklas Baumstark2012-01-25 00:41:47 +0100
committerNiklas Baumstark2012-04-10 23:57:20 +0200
commitb226ddf11348660dc8e9f39dcf7346944082ff67 (patch)
treeb1c91127a40989e6badfd575c8a75388b4dcb343 /lib/completion.js
parent99c19d210f4f7024585eb93d80967377c67fa44e (diff)
downloadvimium-b226ddf11348660dc8e9f39dcf7346944082ff67.tar.bz2
move query length threshold from UI to logic
This enables to set threshold to 0 for tabs (so that tabs are shown before typing).
Diffstat (limited to 'lib/completion.js')
-rw-r--r--lib/completion.js13
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;