summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKris Maglione <maglione.k@gmail.com>2010-12-29 21:49:57 -0500
committerKris Maglione <maglione.k@gmail.com>2010-12-29 21:49:57 -0500
commitf67a50147ed0ee7b493bc7e710fb19befbe23a69 (patch)
tree94ed90dc285f861464b5283b95c068f6d7c05082
parentf9bbe484df24aec41534e4e5dd7343b70358d83c (diff)
downloadpentadactyl-f67a50147ed0ee7b493bc7e710fb19befbe23a69.tar.gz
Cleanup completion.ex parsing and fix it for non-[a-zA-Z]+ commands.
Update issue 216 This should fix your completion problem.
-rw-r--r--common/content/commands.js33
1 files changed, 19 insertions, 14 deletions
diff --git a/common/content/commands.js b/common/content/commands.js
index ef439bb1..75244f24 100644
--- a/common/content/commands.js
+++ b/common/content/commands.js
@@ -1046,13 +1046,15 @@ var Commands = Module("commands", {
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]*
- (\d+ | %)?
- (<name> | !)
- (!)?
+ ([:\s]*)
+ ( (?:\d+ | %)? )
+ ( (?:<name> | !)? )
+ (!?)
(\s*)
)
(
@@ -1082,11 +1084,11 @@ var Commands = Module("commands", {
// remove comments
str.replace(/\s*".*$/, "");
- let matches = this._commandRegexp.exec(str);
- if (!matches)
+ let matches = this.commandRegexp.exec(str);
+ if (!matches || !matches[4])
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] == "|"))
args = null;
@@ -1096,7 +1098,7 @@ var Commands = Module("commands", {
else
count = this.COUNT_NONE;
- return [count, cmd, !!special, args || "", spec.length];
+ return [count, cmd, !!bang, args || "", spec.length];
},
parseCommands: function (str, complete) {
@@ -1218,9 +1220,13 @@ var Commands = Module("commands", {
if (!args)
args = { commandString: context.filter };
- let [, prefix, junk] = args.commandString.match(/^(:*\s*\d*\s*)\w*(.?)/) || [];
- context.advance(prefix.length);
- if (!junk) {
+ let match = commands.commandRegexp.exec(args.commandString);
+ if (!match)
+ 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");
return;
}
@@ -1232,8 +1238,7 @@ var Commands = Module("commands", {
return;
}
- [, prefix] = args.commandString.match(/^[\s\d]*((?:\w*[\s!])?\s*)/);
- let cmdContext = context.fork(command.name, prefix.length);
+ let cmdContext = context.fork(command.name, match.cmd.length + match.bang.length + match.space.length);
try {
if (!cmdContext.waitingForTab) {
if (!args.completeOpt && command.completer && args.completeStart != null) {