# HG changeset patch # User Atul Varma # Date 1238186054 25200 # Node ID 96bb8d08e94ae1cb082f63435464f988a4c9a986 # Parent fd988ee764083dcb45d7f57a3529cddc9f0d280a The 'go' command now uses proper asynchronous suggestions. diff -r fd988ee76408 -r 96bb8d08e94a chromeless-browsing/chromeless.js --- a/chromeless-browsing/chromeless.js Fri Mar 27 13:16:11 2009 -0700 +++ b/chromeless-browsing/chromeless.js Fri Mar 27 13:34:14 2009 -0700 @@ -52,9 +52,7 @@ controller.startSearch(partialSearch); }, - suggestions: [], - _onSearchComplete: function(controller) { - var suggs = []; + _onSearchComplete: function(controller, callback) { var max_suggs = 5; for (var i = 0; i < controller.matchCount && i <= max_suggs; i++) { var result = { @@ -69,25 +67,17 @@ result.image = result.image.slice("moz-anno:favicon:".length); else result.image = ""; - suggs.push(CmdUtils.makeSugg(result.title, undefined, result)); + callback(CmdUtils.makeSugg(result.title, undefined, result)); } - noun_type_url.suggestions = suggs; }, - suggest: function(fragment) { - this._getHistoryLinks(fragment, this._onSearchComplete); - var regexp = /(ftp|http|https):\/\/(\w+:{01}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/; - // Magic words "page" or "url" result in the URL of the current page - if (fragment == "page" || fragment == "url") { - var url = Application.activeWindow.activeTab.document.URL; - this.suggestions.push(CmdUtils.makeSugg(url)); - } - // If it's a valid URL, suggest it back - if (regexp.test(fragment)) { - this.suggestions.push(CmdUtils.makeSugg(fragment)); - } else if (regexp.test("http://" + fragment)) { - this.suggestions.push(CmdUtils.makeSugg("http://" + fragment)); - } - return this.suggestions; + suggest: function(fragment, html, callback) { + var self = this; + this._getHistoryLinks( + fragment, + function(controller) { + self._onSearchComplete(controller, callback); + }); + return [CmdUtils.makeSugg(fragment)]; } };