mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-27 08:15:46 +01:00
add 'wildignore' option
This commit is contained in:
@@ -225,6 +225,7 @@ liberator.Completion = function () //{{{
|
||||
{
|
||||
var dir = "", compl = "";
|
||||
var matches = filter.match(/^(.*[\/\\])?(.*?)$/);
|
||||
|
||||
if (matches)
|
||||
{
|
||||
dir = matches[1] || ""; // "" is expanded inside readDirectory to the current dir
|
||||
@@ -232,9 +233,20 @@ liberator.Completion = function () //{{{
|
||||
}
|
||||
|
||||
var files = [], mapped = [];
|
||||
|
||||
try
|
||||
{
|
||||
files = liberator.io.readDirectory(dir);
|
||||
|
||||
if (liberator.options["wildignore"])
|
||||
{
|
||||
var wimRegexp = new RegExp("(^" + liberator.options["wildignore"].replace(",", "|", "g") + ")$");
|
||||
|
||||
files = files.filter(function (f) {
|
||||
return f.isDirectory() || !wimRegexp.test(f.leafName);
|
||||
});
|
||||
}
|
||||
|
||||
mapped = files.map(function (file) {
|
||||
return [tail ? file.leafName : (dir + file.leafName), file.isDirectory() ? "Directory" : "File"];
|
||||
}).sort(function (a, b) {
|
||||
|
||||
@@ -340,6 +340,25 @@ liberator.CommandLine = function () //{{{
|
||||
},
|
||||
});
|
||||
|
||||
liberator.options.add(["wildignore", "wig"],
|
||||
"List of file patterns to ignore when completing files",
|
||||
"stringlist", "",
|
||||
{
|
||||
validator: function (value)
|
||||
{
|
||||
// TODO: allow for escaping the ","
|
||||
try
|
||||
{
|
||||
new RegExp("^(" + value.replace(",", "|", "g") + ")$");
|
||||
return true;
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
liberator.options.add(["wildoptions", "wop"],
|
||||
"Change how command line completion is done",
|
||||
"stringlist", "",
|
||||
|
||||
Reference in New Issue
Block a user