mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 09:57:59 +01:00
Closes issue #324.
This commit is contained in:
@@ -789,11 +789,9 @@ var Commands = Module("commands", {
|
|||||||
for (let [k, v] in Iterator(extra || []))
|
for (let [k, v] in Iterator(extra || []))
|
||||||
args[k] = v;
|
args[k] = v;
|
||||||
|
|
||||||
var invalid = false;
|
|
||||||
// FIXME: best way to specify these requirements?
|
// FIXME: best way to specify these requirements?
|
||||||
var onlyArgumentsRemaining = allowUnknownOptions || options.length == 0; // after a -- has been found
|
var onlyArgumentsRemaining = allowUnknownOptions || options.length == 0; // after a -- has been found
|
||||||
var arg = null, quoted = null;
|
var arg = null;
|
||||||
var count = 0; // the length of the argument
|
|
||||||
var i = 0;
|
var i = 0;
|
||||||
var completeOpts;
|
var completeOpts;
|
||||||
|
|
||||||
@@ -854,11 +852,10 @@ var Commands = Module("commands", {
|
|||||||
for (let [, opt] in Iterator(options)) {
|
for (let [, opt] in Iterator(options)) {
|
||||||
for (let [, optname] in Iterator(opt.names)) {
|
for (let [, optname] in Iterator(opt.names)) {
|
||||||
if (sub.indexOf(optname) == 0) {
|
if (sub.indexOf(optname) == 0) {
|
||||||
invalid = false;
|
let count = 0;
|
||||||
quoted = null;
|
let invalid = false;
|
||||||
arg = null;
|
let arg, uote, quoted;
|
||||||
quote = null;
|
|
||||||
count = 0;
|
|
||||||
let sep = sub[optname.length];
|
let sep = sub[optname.length];
|
||||||
if (sep == "=" || /\s/.test(sep) && opt.type != CommandOption.NOARG) {
|
if (sep == "=" || /\s/.test(sep) && opt.type != CommandOption.NOARG) {
|
||||||
[count, quoted, quote, error] = getNextArg(sub.substr(optname.length + 1), true);
|
[count, quoted, quote, error] = getNextArg(sub.substr(optname.length + 1), true);
|
||||||
@@ -874,14 +871,14 @@ var Commands = Module("commands", {
|
|||||||
else if (!/\s/.test(sep) && sep != undefined) // this isn't really an option as it has trailing characters, parse it as an argument
|
else if (!/\s/.test(sep) && sep != undefined) // this isn't really an option as it has trailing characters, parse it as an argument
|
||||||
invalid = true;
|
invalid = true;
|
||||||
|
|
||||||
if (complete && !/[\s=]/.test(sep))
|
|
||||||
matchOpts(sub);
|
|
||||||
|
|
||||||
let context = null;
|
let context = null;
|
||||||
if (!complete && quote)
|
if (!complete && quote)
|
||||||
fail("Invalid argument for option " + optname);
|
fail("Invalid argument for option " + optname);
|
||||||
|
|
||||||
if (!invalid) {
|
if (!invalid) {
|
||||||
|
if (complete && !/[\s=]/.test(sep))
|
||||||
|
matchOpts(sub);
|
||||||
|
|
||||||
if (complete && count > 0) {
|
if (complete && count > 0) {
|
||||||
args.completeStart += optname.length + 1;
|
args.completeStart += optname.length + 1;
|
||||||
args.completeOpt = opt;
|
args.completeOpt = opt;
|
||||||
@@ -908,7 +905,7 @@ var Commands = Module("commands", {
|
|||||||
|
|
||||||
// we have a validator function
|
// we have a validator function
|
||||||
if (typeof opt.validator == "function") {
|
if (typeof opt.validator == "function") {
|
||||||
if (opt.validator(arg, quoted) == false) {
|
if (opt.validator(arg, quoted) == false && (arg || !complete)) {
|
||||||
fail("Invalid argument for option: " + optname);
|
fail("Invalid argument for option: " + optname);
|
||||||
if (complete) // Always true.
|
if (complete) // Always true.
|
||||||
complete.highlight(args.completeStart, count - 1, "SPELLCHECK");
|
complete.highlight(args.completeStart, count - 1, "SPELLCHECK");
|
||||||
@@ -939,10 +936,9 @@ var Commands = Module("commands", {
|
|||||||
|
|
||||||
matchOpts(sub);
|
matchOpts(sub);
|
||||||
|
|
||||||
if (complete) {
|
if (complete)
|
||||||
if (argCount == "0" || args.length > 0 && (/[1?]/.test(argCount)))
|
if (argCount == "0" || args.length > 0 && (/[1?]/.test(argCount)))
|
||||||
complete.highlight(i, sub.length, "SPELLCHECK");
|
complete.highlight(i, sub.length, "SPELLCHECK");
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length === literal) {
|
if (args.length === literal) {
|
||||||
if (complete)
|
if (complete)
|
||||||
|
|||||||
@@ -108,8 +108,8 @@ var RangeFinder = Module("rangefinder", {
|
|||||||
this.timeout(function () {
|
this.timeout(function () {
|
||||||
let msg = this.rangeFind.backward ? "find hit TOP, continuing at BOTTOM"
|
let msg = this.rangeFind.backward ? "find hit TOP, continuing at BOTTOM"
|
||||||
: "find hit BOTTOM, continuing at TOP";
|
: "find hit BOTTOM, continuing at TOP";
|
||||||
this.commandline.echo(msg, "Warning", this.commandline.APPEND_TO_MESSAGES
|
this.commandline.echo(msg, "WarningMsg", this.commandline.APPEND_TO_MESSAGES
|
||||||
| this.commandline.FORCE_SINGLELINE);
|
| this.commandline.FORCE_SINGLELINE);
|
||||||
}, 0);
|
}, 0);
|
||||||
else
|
else
|
||||||
this.commandline.echo((this.rangeFind.backward ? "?" : "/") + this.lastFindPattern,
|
this.commandline.echo((this.rangeFind.backward ? "?" : "/") + this.lastFindPattern,
|
||||||
|
|||||||
Reference in New Issue
Block a user