mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-06 15:24:12 +01:00
Allow IDs instead of names in :ext* commands.
This commit is contained in:
@@ -424,11 +424,10 @@ var Addons = Module("addons", {
|
||||
|
||||
AddonManager.getAddonsByTypes(args["-types"], dactyl.wrapCallback(function (list) {
|
||||
if (!args.bang || command.bang) {
|
||||
list = list.filter(function (extension) extension.name == name);
|
||||
if (list.length == 0)
|
||||
return void dactyl.echoerr(_("error.invalidArgument", name));
|
||||
if (!list.every(ok))
|
||||
return void dactyl.echoerr(_("error.invalidOperation"));
|
||||
list = list.filter(function (addon) addon.id == name || addon.name == name);
|
||||
dactyl.assert(list.length, _("error.invalidArgument", name));
|
||||
dactyl.assert(list.some(ok), _("error.invalidOperation"));
|
||||
list = list.filter(ok);
|
||||
}
|
||||
if (command.actions)
|
||||
command.actions(list, this.modules);
|
||||
@@ -439,7 +438,7 @@ var Addons = Module("addons", {
|
||||
argCount: "?", // FIXME: should be "1"
|
||||
bang: true,
|
||||
completer: function (context, args) {
|
||||
completion.extension(context, args["-types"]);
|
||||
completion.addon(context, args["-types"]);
|
||||
context.filters.push(function ({ item }) ok(item));
|
||||
if (command.filter)
|
||||
context.filters.push(command.filter);
|
||||
@@ -477,10 +476,14 @@ var Addons = Module("addons", {
|
||||
};
|
||||
};
|
||||
|
||||
completion.extension = function extension(context, types) {
|
||||
context.title = ["Extension"];
|
||||
completion.addon = function addon(context, types) {
|
||||
context.title = ["Add-on"];
|
||||
context.anchored = false;
|
||||
context.keys = { text: "name", description: "description", icon: "iconURL" },
|
||||
context.keys = {
|
||||
text: function (addon) [addon.name, addon.id],
|
||||
description: "description",
|
||||
icon: "iconURL"
|
||||
};
|
||||
context.generate = function () {
|
||||
context.incomplete = true;
|
||||
AddonManager.getAddonsByTypes(types || ["extension"], function (addons) {
|
||||
|
||||
@@ -842,9 +842,10 @@ var CompletionContext = Class("CompletionContext", {
|
||||
|
||||
Filter: {
|
||||
text: function (item) {
|
||||
let text = Array.concat(item.text);
|
||||
let text = item.texts || Array.concat(item.text);
|
||||
for (let [i, str] in Iterator(text)) {
|
||||
if (this.match(String(str))) {
|
||||
item.texts = text;
|
||||
item.text = String(text[i]);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user