mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-24 00:52:27 +01:00
Prevent infinite loops when trying to execute mappings recursively.
This commit is contained in:
@@ -1018,6 +1018,7 @@ var Events = Module("events", {
|
||||
if (refeed)
|
||||
for (let [i, event] in Iterator(refeed))
|
||||
if (event.originalTarget) {
|
||||
util.dump("Re-feed " + i + " " + refeed.length + " " + (events.toString(event) || "").quote());
|
||||
let evt = events.create(event.originalTarget.ownerDocument, event.type, event);
|
||||
events.dispatch(event.originalTarget, evt, i == 0 && { skipmap: true });
|
||||
}
|
||||
|
||||
@@ -110,7 +110,11 @@ var Map = Class("Map", {
|
||||
if (this.names[0] != ".") // FIXME: Kludge.
|
||||
mappings.repeat = repeat;
|
||||
|
||||
return dactyl.trapErrors(repeat);
|
||||
dactyl.assert(!this.executing, "Attempt to execute mapping recursively");
|
||||
this.executing = true;
|
||||
let res = dactyl.trapErrors(repeat);
|
||||
this.executing = false;
|
||||
return res;
|
||||
}
|
||||
|
||||
}, {
|
||||
|
||||
@@ -387,7 +387,7 @@ var Modes = Module("modes", {
|
||||
}, options);
|
||||
},
|
||||
|
||||
toString: function () this.name,
|
||||
get toStringParams() [this.name],
|
||||
|
||||
valueOf: function () this.id,
|
||||
|
||||
@@ -411,14 +411,14 @@ var Modes = Module("modes", {
|
||||
}),
|
||||
StackElement: (function () {
|
||||
const StackElement = Struct("main", "extended", "params", "saved");
|
||||
StackElement.className = "Modes.StackElement";
|
||||
StackElement.defaultValue("params", function () this.main.params);
|
||||
|
||||
update(StackElement.prototype, {
|
||||
toString: function () !loaded.modes ? this.main : "[mode " +
|
||||
this.main.name +
|
||||
(!this.extended ? "" :
|
||||
"(" + modes.all.filter(function (m) this.extended & m)
|
||||
.join("|") +
|
||||
")") + "]"
|
||||
get toStringParams() !loaded.modes ? this.main.name : [
|
||||
this.main.name,
|
||||
<>({ modes.all.filter(function (m) this.extended & m, this).map(function (m) m.name).join("|") })</>
|
||||
]
|
||||
});
|
||||
return StackElement;
|
||||
})(),
|
||||
|
||||
@@ -769,7 +769,8 @@ Class.prototype = {
|
||||
toString: function () {
|
||||
if (this.toStringParams)
|
||||
var params = "(" + this.toStringParams.map(function (m) isArray(m) ? "[" + m + "]" :
|
||||
isString(m) ? m.quote() : String(m)) + ")";
|
||||
isString(m) ? m.quote() : String(m))
|
||||
.join(", ") + ")";
|
||||
return "[instance " + this.constructor.className + (params || "") + "]";
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user