1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-03-30 18:23:33 +02:00

Fixes issue #640. Hopefully. Given that I've never seen it on any of the dozens of setups I've tested on.

This commit is contained in:
Kris Maglione
2011-09-20 18:53:51 -04:00
parent e0e947ec79
commit d568ce8762
3 changed files with 70 additions and 44 deletions

View File

@@ -1,5 +1,13 @@
# TODO: normalize this debacle of Vim legacy messages # TODO: normalize this debacle of Vim legacy messages
error.damnYouJägermonkey = + \
Hallo. It looks like you've run into a problem resulting from \
overzealous optimizations by the JavaScript engine. We've disabled \
future use of these optimizations, but you'll need to restart your \
browser in order to correct the problems they've caused. You can \
re-enable them by resetting the javascript.options.methodjit.chrome \
preference.
abbreviation.noSuch = No such abbreviation abbreviation.noSuch = No such abbreviation
abbreviation.none = No abbreviations found abbreviation.none = No abbreviations found

View File

@@ -60,7 +60,10 @@ var Messages = Module("messages", {
get: function get(value, default_) { get: function get(value, default_) {
for (let bundle in values(this.bundles)) for (let bundle in values(this.bundles))
try { try {
return bundle.GetStringFromName(value); let res = bundle.GetStringFromName(value);
if (res.slice(0, 2) == "+ ")
return res.slice(2).replace(/\s+/g, " ");
return res;
} }
catch (e) {} catch (e) {}
@@ -73,7 +76,10 @@ var Messages = Module("messages", {
format: function format(value, args, default_) { format: function format(value, args, default_) {
for (let bundle in values(this.bundles)) for (let bundle in values(this.bundles))
try { try {
return bundle.formatStringFromName(value, args, args.length); let res = bundle.formatStringFromName(value, args, args.length);
if (res.slice(0, 2) == "+ ")
return res.slice(2).replace(/\s+/g, " ");
return res;
} }
catch (e) {} catch (e) {}

View File

@@ -428,29 +428,34 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
* @returns [string] The resulting strings. * @returns [string] The resulting strings.
*/ */
debrace: function debrace(pattern) { debrace: function debrace(pattern) {
var res = []; try {
if (isArray(pattern)) { if (isArray(pattern)) {
let rec = function rec(acc) { // Jägermonkey hates us.
let obj = ({
res: [],
rec: function rec(acc) {
let vals; let vals;
while (isString(vals = pattern[acc.length])) while (isString(vals = pattern[acc.length]))
acc.push(vals); acc.push(vals);
if (acc.length == pattern.length) if (acc.length == pattern.length)
res.push(acc.join("")) this.res.push(acc.join(""))
else else
for (let val in values(vals)) for (let val in values(vals))
rec(acc.concat(val)); this.rec(acc.concat(val));
} }
rec([]); });
return res; obj.rec([]);
return obj.res;
} }
if (pattern.indexOf("{") == -1) if (pattern.indexOf("{") == -1)
return [pattern]; return [pattern];
function split(pattern, re, fn, dequote) { let res = [];
let split = function split(pattern, re, fn, dequote) {
let end = 0, match, res = []; let end = 0, match, res = [];
while (match = re.exec(pattern)) { while (match = re.exec(pattern)) {
end = match.index + match[0].length; end = match.index + match[0].length;
@@ -469,7 +474,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
null, ",{}")); null, ",{}"));
}, "{}"); }, "{}");
function rec(acc) { let rec = function rec(acc) {
if (acc.length == patterns.length) if (acc.length == patterns.length)
res.push(array(substrings).zip(acc).flatten().join("")); res.push(array(substrings).zip(acc).flatten().join(""));
else else
@@ -478,6 +483,13 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
} }
rec([]); rec([]);
return res; return res;
}
catch (e if e.message && ~e.message.indexOf("res is undefined")) {
// prefs.safeSet() would be reset on :rehash
prefs.set("javascript.options.methodjit.chrome", false);
util.dactyl.warn(_(UTF8("error.damnYouJägermonkey")));
return [];
}
}, },
/** /**