mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-09 16:44:11 +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:
@@ -340,7 +340,7 @@ var CompletionContext = Class("CompletionContext", {
|
||||
get itemPrototype() {
|
||||
let res = {};
|
||||
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];
|
||||
};
|
||||
for (let i in iter(this.keys, result(this.quote))) {
|
||||
@@ -903,6 +903,13 @@ var Completion = Module("completion", {
|
||||
// depending on the 'complete' option
|
||||
// if the 'complete' argument is passed like "h", it temporarily overrides the complete option
|
||||
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"])
|
||||
var skip = util.regexp("^.*" + this.options["urlseparator"] + "\\s*")
|
||||
|
||||
@@ -354,7 +354,7 @@ var IO = Module("io", {
|
||||
*/
|
||||
listJar: function listJar(file, path) {
|
||||
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(file);
|
||||
try {
|
||||
@@ -366,7 +366,8 @@ var IO = Module("io", {
|
||||
yield entry;
|
||||
}
|
||||
finally {
|
||||
jar.close();
|
||||
if (jar)
|
||||
jar.close();
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -878,6 +879,9 @@ unlet s:cpo_save
|
||||
};
|
||||
|
||||
completion.file = function file(context, full, dir) {
|
||||
if (/^jar:[^!]*$/.test(context.filter))
|
||||
context.advance(4);
|
||||
|
||||
// dir == "" is expanded inside readDirectory to the current dir
|
||||
function getDir(str) str.match(/^(?:.*[\/\\])?/)[0];
|
||||
dir = getDir(dir || context.filter);
|
||||
|
||||
@@ -1722,7 +1722,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
||||
*/
|
||||
trapErrors: function trapErrors(func, self) {
|
||||
try {
|
||||
if (isString(func))
|
||||
if (!callable(func))
|
||||
func = self[func];
|
||||
return func.apply(self || this, Array.slice(arguments, 2));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user