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