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

Fix some args parsing bugs.

--HG--
extra : rebase_source : 1860f8e4e3dd69f26009c704626f41e668ae7e9f
This commit is contained in:
Kris Maglione
2010-10-01 13:25:10 -04:00
parent 572c591979
commit 21514370da
2 changed files with 18 additions and 13 deletions

View File

@@ -784,12 +784,14 @@ const Commands = Module("commands", {
str.replace(/\s*".*$/, "");
// 0 - count, 1 - cmd, 2 - special, 3 - args
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*)?$/);
if (!matches)
return [null, null, null, null];
let [, spec, count, cmd, special, args] = matches;
let [, spec, count, cmd, special, space, args] = matches;
if (/\w/.test(cmd) && args && !space)
args = null;
// parse count
if (count)
@@ -811,7 +813,7 @@ const Commands = Module("commands", {
var context = complete.fork("args", len);
}
if (command && /\w[!\s]/.test(str))
if (command && (!complete || /\w[!\s]/.test(str)))
args = command.parseArgs(args, context, { count: count, bang: bang });
else
args = commands.parseArgs(args, { extra: { count: count, bang: bang } });
@@ -826,6 +828,7 @@ const Commands = Module("commands", {
_subCommands: function (command) {
let commands = [command];
while (command = commands.shift())
try {
for (let [command, args] in this.parseCommands(command)) {
if (command) {
yield [command, args];
@@ -833,6 +836,8 @@ const Commands = Module("commands", {
commands.push(args[command.subCommand]);
}
}
}
catch (e) {}
},
/** @property */
@@ -953,7 +958,7 @@ const Commands = Module("commands", {
let cmdContext = context.fork(command.name, prefix.length);
try {
if (!cmdContext.waitingForTab) {
if (!args.completeOpt && command.completer) {
if (!args.completeOpt && command.completer && args.completeStart != null) {
cmdContext.advance(args.completeStart);
cmdContext.quote = args.quote;
cmdContext.filter = args.completeFilter;

View File

@@ -60,7 +60,7 @@ const CompletionContext = Class("CompletionContext", {
self.__defineGetter__("value", function () this.top.value);
self.offset = parent.offset;
self.advance(offset);
self.advance(offset || 0);
/**
* @property {boolean} Specifies that this context is not finished