diff options
| author | Niklas Baumstark | 2012-01-25 01:21:56 +0100 | 
|---|---|---|
| committer | Niklas Baumstark | 2012-04-10 23:57:20 +0200 | 
| commit | a0d0d8ecfe40a1b802f72dff100185875ee63e2f (patch) | |
| tree | 4fbb645d860a1b1f9beb287d24fd4486e9c4dac2 | |
| parent | ff8e8aa0e22a474b950b551259d330a7705514c3 (diff) | |
| download | vimium-a0d0d8ecfe40a1b802f72dff100185875ee63e2f.tar.bz2 | |
make refresh <F5> work as expected
| -rw-r--r-- | fuzzyMode.js | 1 | ||||
| -rw-r--r-- | lib/completion.js | 15 | 
2 files changed, 13 insertions, 3 deletions
diff --git a/fuzzyMode.js b/fuzzyMode.js index 87b4470a..8d8f1412 100644 --- a/fuzzyMode.js +++ b/fuzzyMode.js @@ -119,6 +119,7 @@ var fuzzyMode = (function() {        // refresh with F5        else if (keyChar == 'f5') {          this.completer.refresh(); +        this.lastQuery = null;          this.update();        } diff --git a/lib/completion.js b/lib/completion.js index b5793437..6aec9e83 100644 --- a/lib/completion.js +++ b/lib/completion.js @@ -104,6 +104,11 @@ var completion = (function() {        return self.matcherCache[query];      } +    /** Clear the cache for the given source, e.g. for refreshing */ +    self.invalidateFilterCache = function(id) { +      self.filterCache[id] = {}; +    } +      /** Filters a collection :source using fuzzy matching against an input string :query. If a query with       * a less specific query was issued before (e.g. if the user added a letter to the query), the cached       * results of the last filtering are used as a starting point, instead of :source. @@ -251,9 +256,6 @@ var completion = (function() {      this.extractStringFromMatch = function(match) { return stripHtmlTags(match.str); }    }    AsyncFuzzyUrlCompleter.prototype = { -    // to be implemented by subclasses -    refresh: function() { }, -      calculateRelevancy: function(query, match) {        return match.url.length /          (fuzzyMatcher.calculateRelevancy(query, this.extractStringFromMatch(match)) + 1); @@ -279,6 +281,10 @@ var completion = (function() {        port.postMessage(query);      }, +    resetCache: function() { +      fuzzyMatcher.invalidateFilterCache(this.id); +    }, +      filter: function(query, callback) {        var self = this; @@ -406,6 +412,7 @@ var completion = (function() {    }    FuzzyHistoryCompleter.prototype = new AsyncFuzzyUrlCompleter;    FuzzyHistoryCompleter.prototype.refresh = function() { +    this.resetCache();      this.fetchFromPort('getHistory', { maxResults: this.maxResults }, function(msg) {        return msg.history.map(function(historyItem) {          return createUrlSuggestion('history', historyItem.url, historyItem.title); @@ -419,6 +426,7 @@ var completion = (function() {    }    FuzzyBookmarkCompleter.prototype = new AsyncFuzzyUrlCompleter;    FuzzyBookmarkCompleter.prototype.refresh = function() { +    this.resetCache();      this.fetchFromPort('getAllBookmarks', {}, function(msg) {        return msg.bookmarks.filter(function(bookmark) { return bookmark.url !== undefined })                            .map(function(bookmark) { @@ -439,6 +447,7 @@ var completion = (function() {      return [ open, open ];    }    FuzzyTabCompleter.prototype.refresh = function() { +    this.resetCache();      this.fetchFromPort('getTabsInCurrentWindow', {}, function(msg) {        return msg.tabs.map(function(tab) {          suggestion = createUrlSuggestion('tab', tab.url, tab.title);  | 
