1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-14 23:35:44 +01:00

better argument processing for :source, :mkvimperatorc, and :saveas

This commit is contained in:
Doug Kearns
2008-10-19 14:13:31 +00:00
parent 337f956323
commit 86460fd8c5
3 changed files with 42 additions and 34 deletions

View File

@@ -897,28 +897,32 @@ function Completion() //{{{
// if "tail" is true, only return names without any directory components
file: function file(filter, tail)
{
let [matches, dir, compl] = filter.match(/^((?:.*[\/\\])?)(.*?)$/);
let [, dir, compl] = filter.match(/^((?:.*[\/\\])?)(.*?)$/);
// dir == "" is expanded inside readDirectory to the current dir
let generate = function ()
{
var files = [], mapped = [];
let files = [], mapped = [];
try
{
dir = dir.replace("\\ ", " ", "g");
files = io.readDirectory(dir, true);
if (options["wildignore"])
{
var wigRegexp = new RegExp("(^" + options["wildignore"].replace(",", "|", "g") + ")$");
let wigRegexp = RegExp("(^" + options["wildignore"].replace(",", "|", "g") + ")$");
files = files.filter(function (f) f.isDirectory() || !wigRegexp.test(f.leafName))
}
mapped = files.map(function (file) [tail ? file.leafName : (dir + file.leafName),
file.isDirectory() ? "Directory" : "File"]);
mapped = files.map(
function (file) [(tail ? file.leafName : dir + file.leafName).replace(" ", "\\ ", "g"),
file.isDirectory() ? "Directory" : "File"]
);
}
catch (e) {}
return mapped;
};