mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 02:17:59 +01:00
Make Option.validateCompleter the default validator: look out for minor breakage.
This commit is contained in:
@@ -264,8 +264,7 @@ const AutoCommands = Module("autocommands", {
|
||||
"List of autocommand event names which should be ignored",
|
||||
"stringlist", "",
|
||||
{
|
||||
completer: function () config.autocommands.concat([["all", "All events"]]),
|
||||
validator: Option.validateCompleter
|
||||
completer: function () config.autocommands.concat([["all", "All events"]])
|
||||
});
|
||||
|
||||
options.add(["focuscontent", "fc"],
|
||||
|
||||
@@ -594,8 +594,7 @@ const Bookmarks = Module("bookmarks", {
|
||||
completer: function completer(context) {
|
||||
completion.search(context, true);
|
||||
context.completions = [["", "Don't perform searches by default"]].concat(context.completions);
|
||||
},
|
||||
validator: Option.validateCompleter
|
||||
}
|
||||
});
|
||||
},
|
||||
completion: function () {
|
||||
|
||||
@@ -49,8 +49,7 @@ const Browser = Module("browser", {
|
||||
}
|
||||
catch (e) { liberator.reportError(e); }
|
||||
},
|
||||
completer: function (context) completion.charset(context),
|
||||
validator: Option.validateCompleter
|
||||
completer: function (context) completion.charset(context)
|
||||
});
|
||||
|
||||
// only available in FF 3.5
|
||||
|
||||
@@ -1612,8 +1612,7 @@ const Buffer = Module("buffer", {
|
||||
"Desired info in the :pageinfo output",
|
||||
"charlist", "gfm",
|
||||
{
|
||||
completer: function (context) [[k, v[1]] for ([k, v] in Iterator(this.pageInfo))],
|
||||
validator: Option.validateCompleter
|
||||
completer: function (context) [[k, v[1]] for ([k, v] in Iterator(this.pageInfo))]
|
||||
});
|
||||
|
||||
options.add(["scroll", "scr"],
|
||||
@@ -1629,8 +1628,7 @@ const Buffer = Module("buffer", {
|
||||
["0", "Don't show link destination"],
|
||||
["1", "Show the link in the status line"],
|
||||
["2", "Show the link in the command line"]
|
||||
],
|
||||
validator: Option.validateCompleter
|
||||
]
|
||||
});
|
||||
|
||||
options.add(["usermode", "um"],
|
||||
|
||||
@@ -1528,16 +1528,14 @@ const CommandLine = Module("commandline", {
|
||||
.filter(function (engine) engine.supportsResponseType("application/x-suggestions+json"));
|
||||
|
||||
return engines.map(function (engine) [engine.alias, engine.description]);
|
||||
},
|
||||
validator: Option.validateCompleter
|
||||
}
|
||||
});
|
||||
|
||||
options.add(["complete", "cpt"],
|
||||
"Items which are completed at the :open prompts",
|
||||
"charlist", typeof(config.defaults["complete"]) == "string" ? config.defaults["complete"] : "slf",
|
||||
{
|
||||
completer: function (context) array(values(completion.urlCompleters)),
|
||||
validator: Option.validateCompleter
|
||||
completer: function (context) array(values(completion.urlCompleters))
|
||||
});
|
||||
|
||||
options.add(["wildcase", "wic"],
|
||||
@@ -1548,8 +1546,7 @@ const CommandLine = Module("commandline", {
|
||||
["smart", "Case is significant when capital letters are typed"],
|
||||
["match", "Case is always significant"],
|
||||
["ignore", "Case is never significant"]
|
||||
],
|
||||
validator: Option.validateCompleter
|
||||
]
|
||||
});
|
||||
|
||||
options.add(["wildignore", "wig"],
|
||||
@@ -1581,7 +1578,6 @@ const CommandLine = Module("commandline", {
|
||||
["list:full", "List all and complete first match"],
|
||||
["list:longest", "List all and complete common string"]
|
||||
],
|
||||
validator: Option.validateCompleter,
|
||||
checkHas: function (value, val) {
|
||||
let [first, second] = value.split(":", 2);
|
||||
return first == val || second == val;
|
||||
@@ -1598,8 +1594,7 @@ const CommandLine = Module("commandline", {
|
||||
["auto", "Automatically show this._completions while you are typing"],
|
||||
["sort", "Always sort the completion list"]
|
||||
];
|
||||
},
|
||||
validator: Option.validateCompleter
|
||||
}
|
||||
});
|
||||
},
|
||||
styles: function () {
|
||||
|
||||
@@ -1100,8 +1100,7 @@ const Hints = Module("hints", {
|
||||
["0", "Follow the first hint as soon as typed text uniquely identifies it. Follow the selected hint on <Return>."],
|
||||
["1", "Follow the selected hint on <Return>."],
|
||||
["2", "Follow the selected hint on <Return> only it's been <Tab>-selected."]
|
||||
],
|
||||
validator: Option.validateCompleter
|
||||
]
|
||||
});
|
||||
|
||||
options.add(["hintmatching", "hm"],
|
||||
@@ -1114,8 +1113,7 @@ const Hints = Module("hints", {
|
||||
["firstletters", "Behaves like wordstartswith, but all groups much match a sequence of words."],
|
||||
["custom", "Delegate to a custom function: liberator.plugins.customHintMatcher(hintString)"],
|
||||
["transliterated", "When true, special latin characters are translated to their ascii equivalent (e.g., \u00e9 -> e)"],
|
||||
],
|
||||
validator: Option.validateCompleter
|
||||
]
|
||||
});
|
||||
|
||||
options.add(["wordseparators", "wsp"],
|
||||
@@ -1130,8 +1128,7 @@ const Hints = Module("hints", {
|
||||
["value", "Match against the value contained by the input field"],
|
||||
["label", "Match against the value of a label for the input field, if one can be found"],
|
||||
["name", "Match against the name of an input field, only if neither a name or value could be found."]
|
||||
],
|
||||
validator: Option.validateCompleter
|
||||
]
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1077,8 +1077,7 @@ lookup:
|
||||
options.add(["fileencoding", "fenc"],
|
||||
"Sets the character encoding of read and written files",
|
||||
"string", "UTF-8", {
|
||||
completer: function (context) completion.charset(context),
|
||||
validator: Option.validateCompleter
|
||||
completer: function (context) completion.charset(context)
|
||||
});
|
||||
options.add(["cdpath", "cd"],
|
||||
"List of directories searched when executing :cd",
|
||||
|
||||
@@ -198,12 +198,7 @@ const Option = Class("Option", {
|
||||
* Returns whether the specified <b>values</b> are valid for this option.
|
||||
* @see Option#validator
|
||||
*/
|
||||
isValidValue: function (values) {
|
||||
if (this.validator)
|
||||
return this.validator(values);
|
||||
else
|
||||
return true;
|
||||
},
|
||||
isValidValue: function (values) this.validator(values),
|
||||
|
||||
/**
|
||||
* Resets the option to its default value.
|
||||
@@ -370,7 +365,11 @@ const Option = Class("Option", {
|
||||
* @property {function} The function called to validate the option's value
|
||||
* when set.
|
||||
*/
|
||||
validator: null,
|
||||
validator: function () {
|
||||
if (this.completer)
|
||||
return Option.validateCompleter.apply(this, arguments);
|
||||
return true;
|
||||
},
|
||||
/**
|
||||
* @property The function called to determine whether the option already
|
||||
* contains a specified value.
|
||||
|
||||
@@ -241,8 +241,7 @@ const Sanitizer = Module("sanitizer", {
|
||||
["passwords", "Saved passwords"],
|
||||
["sessions", "Authenticated sessions"],
|
||||
["sitesettings", "Site preferences"],
|
||||
],
|
||||
validator: Option.validateCompleter
|
||||
]
|
||||
});
|
||||
|
||||
options.add(["sanitizetimespan", "sts"],
|
||||
@@ -260,8 +259,7 @@ const Sanitizer = Module("sanitizer", {
|
||||
["2", "Last two hours"],
|
||||
["3", "Last four hours"],
|
||||
["4", "Today"]
|
||||
],
|
||||
validator: Option.validateCompleter
|
||||
]
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -236,8 +236,7 @@ const StatusLine = Module("statusline", {
|
||||
["0", "Never display status line"],
|
||||
["1", "Display status line only if there are multiple windows"],
|
||||
["2", "Always display status line"]
|
||||
],
|
||||
validator: Option.validateCompleter
|
||||
]
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1056,8 +1056,7 @@ const Tabs = Module("tabs", {
|
||||
["0", "Never show tab bar"],
|
||||
["1", "Show tab bar only if more than one tab is open"],
|
||||
["2", "Always show tab bar"]
|
||||
],
|
||||
validator: Option.validateCompleter
|
||||
]
|
||||
});
|
||||
|
||||
if (config.hasTabbrowser) {
|
||||
@@ -1085,8 +1084,7 @@ const Tabs = Module("tabs", {
|
||||
["help", ":h[elp] command"],
|
||||
["javascript", ":javascript! or :js! command"],
|
||||
["prefs", ":pref[erences]! or :prefs! command"]
|
||||
],
|
||||
validator: Option.validateCompleter
|
||||
]
|
||||
});
|
||||
|
||||
// TODO: Is this really applicable to Xulmus?
|
||||
@@ -1113,8 +1111,7 @@ const Tabs = Module("tabs", {
|
||||
["tab", "Open popups in a new tab"],
|
||||
["window", "Open popups in a new window"],
|
||||
["resized", "Open resized popups in a new window"]
|
||||
],
|
||||
validator: Option.validateCompleter
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user