mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 23:47:58 +01:00
Fix some args parsing bugs.
--HG-- extra : rebase_source : 1860f8e4e3dd69f26009c704626f41e668ae7e9f
This commit is contained in:
@@ -784,12 +784,14 @@ const Commands = Module("commands", {
|
|||||||
str.replace(/\s*".*$/, "");
|
str.replace(/\s*".*$/, "");
|
||||||
|
|
||||||
// 0 - count, 1 - cmd, 2 - special, 3 - args
|
// 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*)?$/);
|
//var matches = str.match(/^:*(\d+|%)?([a-zA-Z]+|!)(!)?(?:\s*(.*?)\s*)?$/);
|
||||||
if (!matches)
|
if (!matches)
|
||||||
return [null, null, null, null];
|
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
|
// parse count
|
||||||
if (count)
|
if (count)
|
||||||
@@ -811,7 +813,7 @@ const Commands = Module("commands", {
|
|||||||
var context = complete.fork("args", len);
|
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 });
|
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 } });
|
||||||
@@ -826,6 +828,7 @@ const Commands = Module("commands", {
|
|||||||
_subCommands: function (command) {
|
_subCommands: function (command) {
|
||||||
let commands = [command];
|
let commands = [command];
|
||||||
while (command = commands.shift())
|
while (command = commands.shift())
|
||||||
|
try {
|
||||||
for (let [command, args] in this.parseCommands(command)) {
|
for (let [command, args] in this.parseCommands(command)) {
|
||||||
if (command) {
|
if (command) {
|
||||||
yield [command, args];
|
yield [command, args];
|
||||||
@@ -833,6 +836,8 @@ const Commands = Module("commands", {
|
|||||||
commands.push(args[command.subCommand]);
|
commands.push(args[command.subCommand]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (e) {}
|
||||||
},
|
},
|
||||||
|
|
||||||
/** @property */
|
/** @property */
|
||||||
@@ -953,7 +958,7 @@ const Commands = Module("commands", {
|
|||||||
let cmdContext = context.fork(command.name, prefix.length);
|
let cmdContext = context.fork(command.name, prefix.length);
|
||||||
try {
|
try {
|
||||||
if (!cmdContext.waitingForTab) {
|
if (!cmdContext.waitingForTab) {
|
||||||
if (!args.completeOpt && command.completer) {
|
if (!args.completeOpt && command.completer && args.completeStart != null) {
|
||||||
cmdContext.advance(args.completeStart);
|
cmdContext.advance(args.completeStart);
|
||||||
cmdContext.quote = args.quote;
|
cmdContext.quote = args.quote;
|
||||||
cmdContext.filter = args.completeFilter;
|
cmdContext.filter = args.completeFilter;
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ const CompletionContext = Class("CompletionContext", {
|
|||||||
self.__defineGetter__("value", function () this.top.value);
|
self.__defineGetter__("value", function () this.top.value);
|
||||||
|
|
||||||
self.offset = parent.offset;
|
self.offset = parent.offset;
|
||||||
self.advance(offset);
|
self.advance(offset || 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {boolean} Specifies that this context is not finished
|
* @property {boolean} Specifies that this context is not finished
|
||||||
|
|||||||
Reference in New Issue
Block a user