diff options
| author | Niklas Baumstark | 2012-01-21 02:53:57 +0100 | 
|---|---|---|
| committer | Niklas Baumstark | 2012-04-10 23:54:35 +0200 | 
| commit | bd6f3bebc41792567b31804f3463119b649cb1e1 (patch) | |
| tree | 8e34597a0fee18425378818616ed48257a0d5c2b /fuzzyMode.js | |
| parent | 2a9c88ae1db8b4eadd5ad815966b1820c5d0af5b (diff) | |
| download | vimium-bd6f3bebc41792567b31804f3463119b649cb1e1.tar.bz2 | |
fix some issues with asynchronous filtering and refreshing
Diffstat (limited to 'fuzzyMode.js')
| -rw-r--r-- | fuzzyMode.js | 32 | 
1 files changed, 14 insertions, 18 deletions
diff --git a/fuzzyMode.js b/fuzzyMode.js index 0387e97b..5588c281 100644 --- a/fuzzyMode.js +++ b/fuzzyMode.js @@ -9,6 +9,7 @@ var fuzzyMode = (function() {            'cc '  : [ 'dict.cc',        'http://www.dict.cc/?s=%s' ],            ';'    : [ 'goto',           '%s' ]          }), +        completer.refresh();          new completion.FuzzyHistoryCompleter(1000),          new completion.FuzzyBookmarkCompleter(),        ]); @@ -27,8 +28,6 @@ var fuzzyMode = (function() {    FuzzyBox.prototype = {      show: function(reverseAction) {        this.reverseAction = reverseAction; -      this.completer.refresh(); -      this.update();        this.box.style.display = 'block';        var self = this;        handlerStack.push({ keydown: function(event) { self.onKeydown(event); }}); @@ -106,30 +105,27 @@ var fuzzyMode = (function() {        this.query = this.query.replace(/^\s*/, '');        this.input.textContent = this.query; -      // clear completions -      this.completions = []; -      while (this.completionList.hasChildNodes()) -        this.completionList.removeChild(this.completionList.firstChild); -        if (this.query.length == 0) {          this.completionList.style.display = 'none';          return;        } -        this.completionList.style.display = 'block'; -      var li; -      var counter = 0;        var self = this; -      this.completer.filter(this.query, function(completion) { -        self.completions.push(completion); -        li = document.createElement('li'); -        li.innerHTML = completion.render(); -        self.completionList.appendChild(li); -        return ++counter < 10; +      this.completer.filter(this.query, function(completions) { +        // clear completions +        self.completions = []; +        while (self.completionList.hasChildNodes()) +          self.completionList.removeChild(self.completionList.firstChild); + +        for (var i = 0; i < completions.length && i < 10; ++i) { +          self.completions.push(completions[i]); +          var li = document.createElement('li'); +          li.innerHTML = completions[i].render(); +          self.completionList.appendChild(li); +        } +        self.updateSelection();        }); - -      this.updateSelection();      },      initDom: function() {  | 
