From 631abed98ddfb6ffbd6da20263df1f6359610ba0 Mon Sep 17 00:00:00 2001
From: Kris Maglione
Date: Wed, 29 Sep 2010 20:30:57 -0400
Subject: [PATCH] Some fixes for stringmap option completion.
---
common/content/commands.js | 9 ++------
common/content/options.js | 38 ++++++++++++++++++++++-----------
common/locale/en-US/options.xml | 16 +++++++-------
3 files changed, 35 insertions(+), 28 deletions(-)
diff --git a/common/content/commands.js b/common/content/commands.js
index 727b234b..16b14bc1 100644
--- a/common/content/commands.js
+++ b/common/content/commands.js
@@ -170,14 +170,9 @@ const Command = Class("Command", {
* @see Commands#parseArgs
*/
parseArgs: function (args, complete, extra) commands.parseArgs(args, {
- allowUnknownOptions: !!this.allowUnknownOptions,
- argCount: this.argCount,
+ __proto__: this,
complete: complete,
- extra: extra,
- hereDoc: this.hereDoc,
- keepQuotes: !!this.keepQuotes,
- literal: this.literal,
- options: this.options
+ extra: extra
}),
/**
diff --git a/common/content/options.js b/common/content/options.js
index e10739e0..c462e26c 100644
--- a/common/content/options.js
+++ b/common/content/options.js
@@ -453,12 +453,14 @@ const Option = Class("Option", {
let res = [];
Option._splitAt = 0;
do {
+ if (count !== undefined)
+ value = value.slice(1);
var [count, arg, quote] = Commands.parseArg(value, /,/, keepQuotes);
Option._quote = quote; // FIXME
res.push(arg);
if (value.length > count)
Option._splitAt += count + 1;
- value = value.slice(count + 1);
+ value = value.slice(count);
} while (value.length);
return res;
},
@@ -494,22 +496,26 @@ const Option = Class("Option", {
},
stringmap: function (operator, values, scope, invert) {
- values = Array.concat(values);
- orig = [k + ":" + v for ([k, v] in Iterator(this.values))];
+ let res = update({}, this.values);
switch (operator) {
+ // The result is the same.
case "+":
- return array.uniq(Array.concat(orig, values), true);
case "^":
- // NOTE: Vim doesn't prepend if there's a match in the current value
- return array.uniq(Array.concat(values, orig), true);
+ return update(res, values);
case "-":
- return orig.filter(function (item) values.indexOf(item) == -1);
+ for (let [k, v] in Iterator(values))
+ if (v === res[k])
+ delete res[k];
+ return res;
case "=":
if (invert) {
- let keepValues = orig.filter(function (item) values.indexOf(item) == -1);
- let addValues = values.filter(function (item) self.values.indexOf(item) == -1);
- return addValues.concat(keepValues);
+ for (let [k, v] in Iterator(values))
+ if (v === res[k])
+ delete res[k];
+ else
+ res[k] = v;
+ return res;
}
return values;
}
@@ -1412,6 +1418,7 @@ const Options = Module("options", {
return;
}
+ let extra = {};
switch (opt.type) {
case "boolean":
if (!completer)
@@ -1425,8 +1432,13 @@ const Options = Module("options", {
case "stringmap":
case "regexmap":
let vals = Option.splitList(context.filter);
- target = vals.pop() || "";
- Option._splitAt += target.indexOf(":") ? target.indexOf(":") + 1 : 0;
+ let target = vals.pop() || "";
+ let [count, key, quote] = Commands.parseArg(target, /:/, true);
+ let split = Option._splitAt;
+ extra.key = Option.dequote(key);
+ extra.value = count < target.length ? Option.dequote(target.substr(count + 1)) : null;
+ extra.values = opt.parseValues(vals.join(","));
+ Option._splitAt = split + (extra.value == null ? 0 : count + 1);
break;
}
// TODO: Highlight when invalid
@@ -1445,7 +1457,7 @@ const Options = Module("options", {
context.filters.push(function (i) curValues.indexOf(i.text) > -1);
}
- let res = completer.call(opt, context);
+ let res = completer.call(opt, context, extra);
if (res)
context.completions = res;
};
diff --git a/common/locale/en-US/options.xml b/common/locale/en-US/options.xml
index 6491919c..5f433c82 100644
--- a/common/locale/en-US/options.xml
+++ b/common/locale/en-US/options.xml
@@ -51,7 +51,7 @@
A comma-separated list of regular expressions. Expressions may be
prefixed with a !, in which case the match will be negated. A
- literal ! at the begining of the expression may be matched
+ literal ! at the beginning of the expression may be matched
with [!] or by placing the regular expression in quotes.
Generally, the first matching regular expression is used. Any comma
appearing within single or double quotes, or prefixed with a
@@ -376,7 +376,7 @@
- To enable autocompletion for everything but :history or
+ To enable auto-completion for everything but :history or
:bmarks, you would choose a value such as
!/ex/bmarks,.?
@@ -401,7 +401,7 @@
on
- Replace occurences of ! with the previous command when
+ Replace occurrences of ! with the previous command when
executing external commands.
@@ -641,7 +641,7 @@
T Toolbar
b Bottom scrollbar
l Left scrollbar (l and r are mutually exclusive)
- m Menubar
+ m Menu bar
n Tab number
r Right scrollbar
@@ -682,7 +682,7 @@
- - value
- The hint is the value displayed in a text input, or the selected option for a dropdown.
+ - value
- The hint is the value displayed in a text input, or the selected option for a drop-down.
- label
- The value of an explicit label for the input; this will not match most manually added labels that are found on sites.
- name
- The name of the input will be used; although the name is not designed for user consumption, it is frequently very similar to the label.
@@ -742,7 +742,7 @@
firstletters
Behaves like wordstartswith, but non-matching words
- aren't overleaped.
+ aren't skipped.
custom
@@ -1113,7 +1113,7 @@
'previouspattern'
'previouspattern'
stringlist
-
+
Patterns to use when guessing the previous page in a document
@@ -1552,7 +1552,7 @@
#*+|=~ _-]]]>
- A regular expression which defines how words are split for the
+ A regular expression which defines how words are split for
the hintmatching types wordstartswith and
firstletters. Words are split on each occurrence of the
given pattern.