diff options
| author | Phil Crosby | 2012-05-04 23:29:26 -0700 |
|---|---|---|
| committer | Phil Crosby | 2012-05-05 18:32:13 -0700 |
| commit | 681a3012ee17ed876c777d88810c3232d3ed10b3 (patch) | |
| tree | 6a6311eb433f04d9b0ae2d126c75d488a06cdf9a /lib | |
| parent | 7a5bbe42a37e0869587196824c474a67726c530e (diff) | |
| download | vimium-681a3012ee17ed876c777d88810c3232d3ed10b3.tar.bz2 | |
Use proxy, and make the bookmark refresh more readable
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/completion.js | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/lib/completion.js b/lib/completion.js index bb869206..13be5551 100644 --- a/lib/completion.js +++ b/lib/completion.js @@ -118,27 +118,24 @@ var completion = (function() { /** A fuzzy bookmark completer */ var FuzzyBookmarkCompletionSource = AsyncCompletionSource.extend({ traverseTree: function(bookmarks, results) { - var self = this; bookmarks.forEach(function(bookmark) { results.push(bookmark); if (bookmark.children === undefined) return; - self.traverseTree(bookmark.children, results); - }); + this.traverseTree(bookmark.children, results); + }.proxy(this)); }, refresh: function() { - var self = this; - self.reset(); + this.reset(); chrome.bookmarks.getTree(function(bookmarks) { var results = []; - self.traverseTree(bookmarks, results); - - self.resultsReady(results.filter(function(b) { return b.url !== undefined; }) - .map(function(bookmark) { - return self.createInternalMatch('bookmark', bookmark); - })); - }); + this.traverseTree(bookmarks, results); + var validResults = results.filter(function(b) { return b.url !== undefined; }); + var matches = validResults.map( + function(bookmark) { return this.createInternalMatch("bookmark", bookmark); }.proxy(this)); + this.resultsReady(matches); + }.proxy(this)); } }); |
