mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 05:58:03 +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)
|
if (!queryURI)
|
||||||
return (callback || util.identity)([]);
|
return (callback || util.identity)([]);
|
||||||
|
|
||||||
function process(resp) {
|
function process(req) {
|
||||||
let results = [];
|
let results = [];
|
||||||
try {
|
try {
|
||||||
results = JSON.parse(resp.responseText)[1].filter(isString);
|
results = JSON.parse(req.responseText)[1].filter(isString);
|
||||||
}
|
}
|
||||||
catch (e) {}
|
catch (e) {}
|
||||||
if (callback)
|
if (callback)
|
||||||
@@ -242,10 +242,10 @@ var Bookmarks = Module("bookmarks", {
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
let resp = util.httpGet(queryURI, callback && process);
|
let req = util.httpGet(queryURI, callback && process);
|
||||||
if (callback)
|
if (callback)
|
||||||
return null;
|
return req;
|
||||||
return process(resp);
|
return process(req);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -659,10 +659,17 @@ var Bookmarks = Module("bookmarks", {
|
|||||||
ctxt.title = [engine.description + " Suggestions"];
|
ctxt.title = [engine.description + " Suggestions"];
|
||||||
ctxt.keys = { text: util.identity, description: function () "" };
|
ctxt.keys = { text: util.identity, description: function () "" };
|
||||||
ctxt.compare = CompletionContext.Sort.unsorted;
|
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;
|
ctxt.incomplete = true;
|
||||||
bookmarks.getSuggestions(name, ctxt.filter, function (compl) {
|
ctxt.cache.request = bookmarks.getSuggestions(name, ctxt.filter, function (compl) {
|
||||||
ctxt.incomplete = false;
|
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);
|
util.addObserver(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
cleanup: function () {
|
destroy: function () {
|
||||||
this.cleanupProgressListener();
|
this.cleanupProgressListener();
|
||||||
this.observe.unregister();
|
this.observe.unregister();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1083,6 +1083,7 @@ var CommandLine = Module("commandline", {
|
|||||||
this.context.updateAsync = true;
|
this.context.updateAsync = true;
|
||||||
this.reset(show, tabPressed);
|
this.reset(show, tabPressed);
|
||||||
this.wildIndex = 0;
|
this.wildIndex = 0;
|
||||||
|
this._caret = this.caret;
|
||||||
},
|
},
|
||||||
|
|
||||||
haveType: function haveType(type)
|
haveType: function haveType(type)
|
||||||
@@ -1270,7 +1271,7 @@ var CommandLine = Module("commandline", {
|
|||||||
break;
|
break;
|
||||||
case "longest":
|
case "longest":
|
||||||
if (this.items.length > 1) {
|
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;
|
this.completion = this.substring;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1523,7 +1523,7 @@ var Events = Module("events", {
|
|||||||
setter: function (values) {
|
setter: function (values) {
|
||||||
values.forEach(function (filter) {
|
values.forEach(function (filter) {
|
||||||
filter.result = events.fromString(filter.result).map(events.closure.toString);
|
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;
|
return values;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -325,15 +325,15 @@ var Config = Module("config", ConfigBase, {
|
|||||||
searchRunning = context;
|
searchRunning = context;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
completion.addUrlCompleter("l",
|
||||||
|
"Firefox location bar entries (bookmarks and history sorted in an intelligent way)",
|
||||||
|
completion.location);
|
||||||
|
|
||||||
completion.sidebar = function sidebar(context) {
|
completion.sidebar = function sidebar(context) {
|
||||||
let menu = document.getElementById("viewSidebarMenu");
|
let menu = document.getElementById("viewSidebarMenu");
|
||||||
context.title = ["Sidebar Panel"];
|
context.title = ["Sidebar Panel"];
|
||||||
context.completions = Array.map(menu.childNodes, function (n) [n.getAttribute("label"), ""]);
|
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) {
|
events: function (dactyl, modules, window) {
|
||||||
modules.events.listen(window, "SidebarFocused", function (event) {
|
modules.events.listen(window, "SidebarFocused", function (event) {
|
||||||
|
|||||||
Reference in New Issue
Block a user