1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 00:17:58 +01:00

Fix some completion issues. Make async search suggestion completions somewhat more useable.

This commit is contained in:
Kris Maglione
2011-02-18 22:25:36 -05:00
parent ce23dd079d
commit cb0a07ddd1
5 changed files with 22 additions and 14 deletions

View File

@@ -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);
});
});
};

View File

@@ -18,7 +18,7 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase),
util.addObserver(this);
},
cleanup: function () {
destroy: function () {
this.cleanupProgressListener();
this.observe.unregister();
},

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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) {