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

fix :command listing and remove broken option filtering as it doesn't seem

generally useful
This commit is contained in:
Doug Kearns
2008-11-11 14:50:31 +00:00
parent d0a42ac0f9
commit 5ed314964e

View File

@@ -170,23 +170,6 @@ function Commands() //{{{
var exCommands = []; var exCommands = [];
function getMatchingUserCommands(name, filter)
{
var matches = [];
for (let [,cmd] in Iterator(exCommands))
{
if (cmd.isUserCommand)
{
if (!name || cmd.name.match("^" + name))
{
if (util.map(filter, function (f) f).every(function ([k, v]) v == null || cmd[k] == v))
matches.push(cmd);
}
}
}
return matches;
}
function parseBool(arg) function parseBool(arg)
{ {
if (arg == "true" || arg == "1" || arg == "on") if (arg == "true" || arg == "1" || arg == "on")
@@ -725,6 +708,7 @@ function Commands() //{{{
function (args, special) function (args, special)
{ {
let cmd = args.arguments[0]; let cmd = args.arguments[0];
if (cmd != null && /\W/.test(cmd)) if (cmd != null && /\W/.test(cmd))
{ {
liberator.echoerr("E182: Invalid command name"); liberator.echoerr("E182: Invalid command name");
@@ -755,12 +739,9 @@ function Commands() //{{{
} }
else else
{ {
let filter = { // TODO: using an array comprehension here generates flakey results across repeated calls
argCount: args["-nargs"], // : perhaps we shouldn't allow options in a list call but just ignore them for now
bang: "-bang" in args && true, // XXX: ??? let cmds = exCommands.filter(function (c) c.isUserCommand && (!cmd || c.name.match("^" + cmd)));
count: args["-count"]
};
let cmds = getMatchingUserCommands(cmd, filter);
if (cmds.length > 0) if (cmds.length > 0)
{ {