diff --git a/common/content/bookmarks.js b/common/content/bookmarks.js index f6b25df6..b0443396 100644 --- a/common/content/bookmarks.js +++ b/common/content/bookmarks.js @@ -231,10 +231,10 @@ var Bookmarks = Module("bookmarks", { if (!queryURI) return (callback || util.identity)([]); - function process(resp) { + function process(req) { let results = []; try { - results = JSON.parse(resp.responseText)[1].filter(isString); + results = JSON.parse(req.responseText)[1].filter(isString); } catch (e) {} if (callback) @@ -242,10 +242,10 @@ var Bookmarks = Module("bookmarks", { return results; } - let resp = util.httpGet(queryURI, callback && process); + let req = util.httpGet(queryURI, callback && process); if (callback) - return null; - return process(resp); + return req; + return process(req); }, /** @@ -659,10 +659,17 @@ var Bookmarks = Module("bookmarks", { ctxt.title = [engine.description + " Suggestions"]; ctxt.keys = { text: util.identity, description: function () "" }; ctxt.compare = CompletionContext.Sort.unsorted; + ctxt.filterFunc = null; + + let words = ctxt.filter.split(/\s+/g); + ctxt.completions = ctxt.completions.filter(function (i) words.every(function (w) i.toLowerCase().indexOf(w) >= 0)); + + ctxt.hasItems = ctxt.completions.length; ctxt.incomplete = true; - bookmarks.getSuggestions(name, ctxt.filter, function (compl) { + ctxt.cache.request = bookmarks.getSuggestions(name, ctxt.filter, function (compl) { ctxt.incomplete = false; - ctxt.completions = compl; + ctxt.completions = array.uniq(ctxt.completions.filter(function (c) compl.indexOf(c) >= 0) + .concat(compl), true); }); }); }; diff --git a/common/content/browser.js b/common/content/browser.js index 20af05b4..3400f8a1 100644 --- a/common/content/browser.js +++ b/common/content/browser.js @@ -18,7 +18,7 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), util.addObserver(this); }, - cleanup: function () { + destroy: function () { this.cleanupProgressListener(); this.observe.unregister(); }, diff --git a/common/content/commandline.js b/common/content/commandline.js index 4c0ec41a..28e30544 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -1083,6 +1083,7 @@ var CommandLine = Module("commandline", { this.context.updateAsync = true; this.reset(show, tabPressed); this.wildIndex = 0; + this._caret = this.caret; }, haveType: function haveType(type) @@ -1270,7 +1271,7 @@ var CommandLine = Module("commandline", { break; case "longest": if (this.items.length > 1) { - if (this.substring && this.substring != this.completion) + if (this.substring && this.substring.length > this.completion.length) this.completion = this.substring; break; } diff --git a/common/content/events.js b/common/content/events.js index a4cb6d8f..9f51d72a 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -1523,7 +1523,7 @@ var Events = Module("events", { setter: function (values) { values.forEach(function (filter) { filter.result = events.fromString(filter.result).map(events.closure.toString); - filter.result.toString = function toString() this.join(""); + filter.result.toString = bind(filter.results.join, filter.results); }); return values; } diff --git a/pentadactyl/content/config.js b/pentadactyl/content/config.js index 66d97443..44f1d766 100644 --- a/pentadactyl/content/config.js +++ b/pentadactyl/content/config.js @@ -325,15 +325,15 @@ var Config = Module("config", ConfigBase, { searchRunning = context; }; + completion.addUrlCompleter("l", + "Firefox location bar entries (bookmarks and history sorted in an intelligent way)", + completion.location); + completion.sidebar = function sidebar(context) { let menu = document.getElementById("viewSidebarMenu"); context.title = ["Sidebar Panel"]; context.completions = Array.map(menu.childNodes, function (n) [n.getAttribute("label"), ""]); }; - - completion.addUrlCompleter("l", - "Firefox location bar entries (bookmarks and history sorted in an intelligent way)", - completion.location); }, events: function (dactyl, modules, window) { modules.events.listen(window, "SidebarFocused", function (event) {