Skip to content

Instantly share code, notes, and snippets.

@mooz
Created January 26, 2010 11:48
Show Gist options
  • Save mooz/286772 to your computer and use it in GitHub Desktop.
Save mooz/286772 to your computer and use it in GitHub Desktop.
key.setViewKey('o', function (aEvent) {
prompt.reader(
{
message : "Find file:",
group : "find-file",
flags : [ICON | IGNORE, 0],
completer : completer.fetch.directory(
{
// hideDotFiles : true,
// mask : /\.(js|jpg|jpeg)$/,
filter: function (collection, query) {
let matched = [];
let remains = collection;
// head
remains = remains.filter(function (c) {
if (c.indexOf(query) === 0) { matched.push(c); return false; }
return true;
});
// ignore case
let (query = query.toLowerCase())
remains = remains.filter(function (c) {
if (c.toLowerCase().indexOf(query.toLowerCase()) === 0) { matched.push(c); return false; }
return true;
});
if ("xulMigemoCore" in window)
return matched.concat(remains.filter(function (c) c.match(window.xulMigemoCore.getRegExp(query))));
return matched;
}
}
),
callback : function (query) {
if (query)
{
openUILinkIn(util.pathToURL(query), "tab");
}
}
}
);
}, 'Find file');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment