mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 13:47:57 +01:00
Cleanup completion.ex parsing and fix it for non-[a-zA-Z]+ commands.
Update issue 216 This should fix your completion problem.
This commit is contained in:
@@ -1046,13 +1046,15 @@ var Commands = Module("commands", {
|
|||||||
|
|
||||||
validName: Class.memoize(function () RegExp("^" + this.nameRegexp.source + "$")),
|
validName: Class.memoize(function () RegExp("^" + this.nameRegexp.source + "$")),
|
||||||
|
|
||||||
_commandRegexp: Class.memoize(function () util.regexp(<![CDATA[
|
CommandMatch: Struct("match", "spec", "prespace", "count", "cmd", "bang", "space", "args"),
|
||||||
|
|
||||||
|
commandRegexp: Class.memoize(function () util.regexp(<![CDATA[
|
||||||
^
|
^
|
||||||
(
|
(
|
||||||
[:\s]*
|
([:\s]*)
|
||||||
(\d+ | %)?
|
( (?:\d+ | %)? )
|
||||||
(<name> | !)
|
( (?:<name> | !)? )
|
||||||
(!)?
|
(!?)
|
||||||
(\s*)
|
(\s*)
|
||||||
)
|
)
|
||||||
(
|
(
|
||||||
@@ -1082,11 +1084,11 @@ var Commands = Module("commands", {
|
|||||||
// remove comments
|
// remove comments
|
||||||
str.replace(/\s*".*$/, "");
|
str.replace(/\s*".*$/, "");
|
||||||
|
|
||||||
let matches = this._commandRegexp.exec(str);
|
let matches = this.commandRegexp.exec(str);
|
||||||
if (!matches)
|
if (!matches || !matches[4])
|
||||||
return [];
|
return [];
|
||||||
|
|
||||||
let [, spec, count, cmd, special, space, args] = matches;
|
let [, spec, prespace, count, cmd, bang, space, args] = matches;
|
||||||
if (/\w/.test(cmd) && args && !(space || args[0] == "|"))
|
if (/\w/.test(cmd) && args && !(space || args[0] == "|"))
|
||||||
args = null;
|
args = null;
|
||||||
|
|
||||||
@@ -1096,7 +1098,7 @@ var Commands = Module("commands", {
|
|||||||
else
|
else
|
||||||
count = this.COUNT_NONE;
|
count = this.COUNT_NONE;
|
||||||
|
|
||||||
return [count, cmd, !!special, args || "", spec.length];
|
return [count, cmd, !!bang, args || "", spec.length];
|
||||||
},
|
},
|
||||||
|
|
||||||
parseCommands: function (str, complete) {
|
parseCommands: function (str, complete) {
|
||||||
@@ -1218,9 +1220,13 @@ var Commands = Module("commands", {
|
|||||||
if (!args)
|
if (!args)
|
||||||
args = { commandString: context.filter };
|
args = { commandString: context.filter };
|
||||||
|
|
||||||
let [, prefix, junk] = args.commandString.match(/^(:*\s*\d*\s*)\w*(.?)/) || [];
|
let match = commands.commandRegexp.exec(args.commandString);
|
||||||
context.advance(prefix.length);
|
if (!match)
|
||||||
if (!junk) {
|
return;
|
||||||
|
match = commands.CommandMatch.apply(null, match);
|
||||||
|
|
||||||
|
context.advance(match.prespace.length + match.count.length);
|
||||||
|
if (!(match.bang || match.space)) {
|
||||||
context.fork("", 0, this, "command");
|
context.fork("", 0, this, "command");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1232,8 +1238,7 @@ var Commands = Module("commands", {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
[, prefix] = args.commandString.match(/^[\s\d]*((?:\w*[\s!])?\s*)/);
|
let cmdContext = context.fork(command.name, match.cmd.length + match.bang.length + match.space.length);
|
||||||
let cmdContext = context.fork(command.name, prefix.length);
|
|
||||||
try {
|
try {
|
||||||
if (!cmdContext.waitingForTab) {
|
if (!cmdContext.waitingForTab) {
|
||||||
if (!args.completeOpt && command.completer && args.completeStart != null) {
|
if (!args.completeOpt && command.completer && args.completeStart != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user