1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-31 05:25:47 +01:00

Fix some unnecessary error reports for invalid jar: URLs. Also complete the JAR file portion of the URL.

This commit is contained in:
Kris Maglione
2011-03-10 10:58:02 -05:00
parent d7b68c66af
commit b7a3f8d2fb
3 changed files with 15 additions and 4 deletions

View File

@@ -340,7 +340,7 @@ var CompletionContext = Class("CompletionContext", {
get itemPrototype() { get itemPrototype() {
let res = {}; let res = {};
function result(quote) { function result(quote) {
yield ["result", quote ? function () quote[0] + quote[1](this.text) + quote[2] yield ["result", quote ? function () quote[0] + util.trapErrors(1, quote, this.text) + quote[2]
: function () this.text]; : function () this.text];
}; };
for (let i in iter(this.keys, result(this.quote))) { for (let i in iter(this.keys, result(this.quote))) {
@@ -903,6 +903,13 @@ var Completion = Module("completion", {
// depending on the 'complete' option // depending on the 'complete' option
// if the 'complete' argument is passed like "h", it temporarily overrides the complete option // if the 'complete' argument is passed like "h", it temporarily overrides the complete option
url: function url(context, complete) { url: function url(context, complete) {
if (/^jar:[^!]*$/.test(context.filter)) {
context.advance(4);
context.quote = context.quote || ["", util.identity, ""];
let quote = context.quote[1];
context.quote[1] = function (str) quote(str.replace(/!/g, escape));
}
if (this.options["urlseparator"]) if (this.options["urlseparator"])
var skip = util.regexp("^.*" + this.options["urlseparator"] + "\\s*") var skip = util.regexp("^.*" + this.options["urlseparator"] + "\\s*")

View File

@@ -354,7 +354,7 @@ var IO = Module("io", {
*/ */
listJar: function listJar(file, path) { listJar: function listJar(file, path) {
file = util.getFile(file); file = util.getFile(file);
if (file) { if (file && file.exists() && file.isFile() && file.isReadable()) {
// let jar = services.zipReader.getZip(file); Crashes. // let jar = services.zipReader.getZip(file); Crashes.
let jar = services.ZipReader(file); let jar = services.ZipReader(file);
try { try {
@@ -366,7 +366,8 @@ var IO = Module("io", {
yield entry; yield entry;
} }
finally { finally {
jar.close(); if (jar)
jar.close();
} }
} }
}, },
@@ -878,6 +879,9 @@ unlet s:cpo_save
}; };
completion.file = function file(context, full, dir) { completion.file = function file(context, full, dir) {
if (/^jar:[^!]*$/.test(context.filter))
context.advance(4);
// dir == "" is expanded inside readDirectory to the current dir // dir == "" is expanded inside readDirectory to the current dir
function getDir(str) str.match(/^(?:.*[\/\\])?/)[0]; function getDir(str) str.match(/^(?:.*[\/\\])?/)[0];
dir = getDir(dir || context.filter); dir = getDir(dir || context.filter);

View File

@@ -1722,7 +1722,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
*/ */
trapErrors: function trapErrors(func, self) { trapErrors: function trapErrors(func, self) {
try { try {
if (isString(func)) if (!callable(func))
func = self[func]; func = self[func];
return func.apply(self || this, Array.slice(arguments, 2)); return func.apply(self || this, Array.slice(arguments, 2));
} }