From 0ab64a092def03ccd462802f040d83ce2911ea1e Mon Sep 17 00:00:00 2001 From: Niklas Baumstark Date: Wed, 25 Jan 2012 22:32:08 +0100 Subject: really only update every X milliseconds --- fuzzyMode.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'fuzzyMode.js') diff --git a/fuzzyMode.js b/fuzzyMode.js index a2ff7dc5..2a9b4601 100644 --- a/fuzzyMode.js +++ b/fuzzyMode.js @@ -75,8 +75,7 @@ var fuzzyMode = (function() { reset: function() { this.query = ''; - // query used to filter the last completion result. We need this for asynchronous updating - this.lastQuery = null; + this.updateTimer = null; this.completions = []; this.selection = 0; // force synchronous updating so that the old results will not be flash up shortly @@ -121,8 +120,7 @@ var fuzzyMode = (function() { // refresh with F5 else if (keyChar == 'f5') { this.completer.refresh(); - this.lastQuery = null; - this.update(); + this.update(true); // force synchronous update } // use primary action with Enter. Holding down Shift/Ctrl uses the alternative action @@ -150,6 +148,7 @@ var fuzzyMode = (function() { updateCompletions: function() { var self = this; + var start = Date.now(); this.completer.filter(this.query, this.maxResults, function(completions) { self.completions = completions; @@ -157,6 +156,7 @@ var fuzzyMode = (function() { self.completionList.innerHTML = completions.map(function(completion) { return '