mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 11:18:00 +01:00
Some fixes for stringmap option completion.
This commit is contained in:
@@ -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
|
||||
}),
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
<dd>
|
||||
A comma-separated list of regular expressions. Expressions may be
|
||||
prefixed with a <em>!</em>, in which case the match will be negated. A
|
||||
literal <em>!</em> at the begining of the expression may be matched
|
||||
literal <em>!</em> at the beginning of the expression may be matched
|
||||
with <em>[!]</em> 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 @@
|
||||
</p>
|
||||
|
||||
<example>
|
||||
To enable autocompletion for everything but <ex>:history</ex> or
|
||||
To enable auto-completion for everything but <ex>:history</ex> or
|
||||
<ex>:bmarks</ex>, you would choose a value such as
|
||||
<str delim="'">!/ex/bmarks,.?</str>
|
||||
</example>
|
||||
@@ -401,7 +401,7 @@
|
||||
<default>on</default>
|
||||
<description>
|
||||
<p>
|
||||
Replace occurences of ! with the previous command when
|
||||
Replace occurrences of ! with the previous command when
|
||||
executing external commands.
|
||||
</p>
|
||||
</description>
|
||||
@@ -682,7 +682,7 @@
|
||||
</p>
|
||||
|
||||
<dl>
|
||||
<dt>value</dt> <dd>The hint is the value displayed in a text input, or the selected option for a dropdown.</dd>
|
||||
<dt>value</dt> <dd>The hint is the value displayed in a text input, or the selected option for a drop-down.</dd>
|
||||
<dt>label</dt> <dd>The value of an explicit label for the input; this will not match most manually added labels that are found on sites.</dd>
|
||||
<dt>name </dt> <dd>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.</dd>
|
||||
</dl>
|
||||
@@ -742,7 +742,7 @@
|
||||
<dt>firstletters</dt>
|
||||
<dd>
|
||||
Behaves like wordstartswith, but non-matching words
|
||||
aren't overleaped.
|
||||
aren't skipped.
|
||||
</dd>
|
||||
<dt>custom</dt>
|
||||
<dd>
|
||||
@@ -1113,7 +1113,7 @@
|
||||
<tags>'previouspattern'</tags>
|
||||
<spec>'previouspattern'</spec>
|
||||
<type>stringlist</type>
|
||||
<default><![CDATA[\bprev|previous\b,^<$,^(<<|«)$,^(<|«),(<|«)$]]></default>
|
||||
<default><![CDATA['\bprev|previous\b',^<$,'^(<<|«)$','^(<|«)','(<|«)$']]></default>
|
||||
<description>
|
||||
<p>
|
||||
Patterns to use when guessing the previous page in a document
|
||||
@@ -1552,7 +1552,7 @@
|
||||
<default><![CDATA[[.,!?:;\\/"^$%&?()[\]{}<>#*+|=~ _-]]]></default>
|
||||
<description>
|
||||
<p>
|
||||
A regular expression which defines how words are split for the
|
||||
A regular expression which defines how words are split for
|
||||
the <o>hintmatching</o> types <str>wordstartswith</str> and
|
||||
<str>firstletters</str>. Words are split on each occurrence of the
|
||||
given pattern.
|
||||
|
||||
Reference in New Issue
Block a user