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

Fix error message for non-existent commands in a "|" separated command line.

This commit is contained in:
Doug Kearns
2010-10-07 00:48:33 +11:00
parent 3aefc2ef99
commit b23227f20b

View File

@@ -795,7 +795,7 @@ const Commands = Module("commands", {
let matches = str.match(/^([:\s]*(\d+|%)?([a-zA-Z]+|!)(!)?(\s*))(.*?)?$/); let matches = str.match(/^([:\s]*(\d+|%)?([a-zA-Z]+|!)(!)?(\s*))(.*?)?$/);
//var matches = str.match(/^:*(\d+|%)?([a-zA-Z]+|!)(!)?(?:\s*(.*?)\s*)?$/); //var matches = str.match(/^:*(\d+|%)?([a-zA-Z]+|!)(!)?(?:\s*(.*?)\s*)?$/);
if (!matches) if (!matches)
return [null, null, null, null]; return [];
let [, spec, count, cmd, special, space, args] = matches; let [, spec, count, cmd, special, space, args] = matches;
if (/\w/.test(cmd) && args && !(space || args[0] == "|")) if (/\w/.test(cmd) && args && !(space || args[0] == "|"))
@@ -813,18 +813,19 @@ const Commands = Module("commands", {
parseCommands: function (str, complete) { parseCommands: function (str, complete) {
do { do {
let [count, cmd, bang, args, len] = commands.parseCommand(str); let [count, cmd, bang, args, len] = commands.parseCommand(str);
if (cmd == null) { let command = commands.get(cmd || "");
if (command == null) {
yield [null, { commandString: str }]; yield [null, { commandString: str }];
return; return;
} }
let command = commands.get(cmd); if (complete) {
if (command && complete) {
complete.fork(command.name); complete.fork(command.name);
var context = complete.fork("args", len); var context = complete.fork("args", len);
} }
if (command && (!complete || /\w[!\s]/.test(str))) if (!complete || /\w[!\s]/.test(str))
args = command.parseArgs(args, context, { count: count, bang: bang }); args = command.parseArgs(args, context, { count: count, bang: bang });
else else
args = commands.parseArgs(args, { extra: { count: count, bang: bang } }); args = commands.parseArgs(args, { extra: { count: count, bang: bang } });