mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 00:28:00 +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,13 +828,16 @@ const Commands = Module("commands", {
|
|||||||
_subCommands: function (command) {
|
_subCommands: function (command) {
|
||||||
let commands = [command];
|
let commands = [command];
|
||||||
while (command = commands.shift())
|
while (command = commands.shift())
|
||||||
for (let [command, args] in this.parseCommands(command)) {
|
try {
|
||||||
if (command) {
|
for (let [command, args] in this.parseCommands(command)) {
|
||||||
yield [command, args];
|
if (command) {
|
||||||
if (command.subCommand && args[command.subCommand])
|
yield [command, args];
|
||||||
commands.push(args[command.subCommand]);
|
if (command.subCommand && 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
|
||||||
@@ -449,9 +449,9 @@ const CompletionContext = Class("CompletionContext", {
|
|||||||
this.cache.constructed = items.map(function (item) Object.create(proto, { item: { value: item, enumerable: true } }));
|
this.cache.constructed = items.map(function (item) Object.create(proto, { item: { value: item, enumerable: true } }));
|
||||||
|
|
||||||
// Filters
|
// Filters
|
||||||
let filtered = this.filterFunc(this.cache.constructed);
|
let filtered = this.filterFunc(this.cache.constructed);
|
||||||
if (this.maxItems)
|
if (this.maxItems)
|
||||||
filtered = filtered.slice(0, this.maxItems);
|
filtered = filtered.slice(0, this.maxItems);
|
||||||
|
|
||||||
// Sorting
|
// Sorting
|
||||||
if (this.sortResults && this.compare)
|
if (this.sortResults && this.compare)
|
||||||
|
|||||||
Reference in New Issue
Block a user