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:
@@ -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);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -18,7 +18,7 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase),
|
||||
util.addObserver(this);
|
||||
},
|
||||
|
||||
cleanup: function () {
|
||||
destroy: function () {
|
||||
this.cleanupProgressListener();
|
||||
this.observe.unregister();
|
||||
},
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user