mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 05:17:58 +01:00
Fix some option validators. Closes issue #78.
This commit is contained in:
@@ -597,8 +597,12 @@ const CompletionContext = Class("CompletionContext", {
|
|||||||
|
|
||||||
if (!context.autoComplete && !context.tabPressed && context.editor)
|
if (!context.autoComplete && !context.tabPressed && context.editor)
|
||||||
context.waitingForTab = true;
|
context.waitingForTab = true;
|
||||||
else if (completer)
|
else if (completer) {
|
||||||
return completer.apply(self || this, [context].concat(Array.slice(arguments, fork.length)));
|
let res = completer.apply(self || this, [context].concat(Array.slice(arguments, fork.length)));
|
||||||
|
if (res && !isArray(res) && !isArray(res.__proto__))
|
||||||
|
return [k for (k in res)];
|
||||||
|
return res;
|
||||||
|
}
|
||||||
if (completer)
|
if (completer)
|
||||||
return null;
|
return null;
|
||||||
return context;
|
return context;
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
/** @scope modules */
|
/** @scope modules */
|
||||||
|
|
||||||
|
let ValueError = Class("ValueError", Error);
|
||||||
|
|
||||||
// do NOT create instances of this class yourself, use the helper method
|
// do NOT create instances of this class yourself, use the helper method
|
||||||
// options.add() instead
|
// options.add() instead
|
||||||
/**
|
/**
|
||||||
@@ -227,6 +229,8 @@ const Option = Class("Option", {
|
|||||||
return this.invalidArgument(str || this.stringify(values), operator);
|
return this.invalidArgument(str || this.stringify(values), operator);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
if (!(e instanceof ValueError))
|
||||||
|
dactyl.reportError(e);
|
||||||
return this.invalidArgument(str || this.stringify(values), operator) + ": " + e.message;
|
return this.invalidArgument(str || this.stringify(values), operator) + ": " + e.message;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -563,7 +567,7 @@ const Option = Class("Option", {
|
|||||||
validIf: function (test, error) {
|
validIf: function (test, error) {
|
||||||
if (test)
|
if (test)
|
||||||
return true;
|
return true;
|
||||||
throw Error(error);
|
throw ValueError(error);
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO: Run this by default?
|
// TODO: Run this by default?
|
||||||
|
|||||||
Reference in New Issue
Block a user