Commit d911530e authored by Leon Arnott's avatar Leon Arnott
Browse files

Fixed two more bugs.

* Fixed a bug where custom macros couldn't call other custom macros if the other macro's (output:) or (output-hook:) was inside a nested hook, such as an (if:) hook.
* Fixed a bug where (icon-restart:) didn't restart the story when clicked.
parent 04586875cfa9
......@@ -10,6 +10,8 @@ Documentation is at http://twine2.neocities.org/. See below for compilation inst
* Fixed a bug where `bind` and `2bind` wouldn't work properly when used to bind a data structure's data name (such as `bind $list's 1st`).
* Fixed a bug where error messages would incorrectly call custom macros' parameters "a number" even if that parameter was restricted to something else.
* Fixed a code generation bug in the "The passage ___ was visited" option of the "If" pane of the editor toolbar.
* Fixed a bug where custom macros couldn't call other custom macros if the other macro's `(output:)` or `(output-hook:)` was inside a nested hook, such as an `(if:)` hook.
* Fixed a bug where `(icon-restart:)` didn't restart the story when clicked.
### 3.2.1 changes (Jan 18, 2021):
......
......@@ -140,7 +140,7 @@ define(['jquery','utils/operationutils','internaltypes/changedescriptor', 'inter
The stack frame itself needs to be in a variable because .execute() will pop it off the stackTop.
*/
let output, dom = $('<p>').append(body.html);
let stackSize = section.stack.length;
section.stack.unshift({
tempVariables,
dom,
......@@ -157,11 +157,11 @@ define(['jquery','utils/operationutils','internaltypes/changedescriptor', 'inter
});
section.execute();
/*
Section.execute() doesn't pop the stack frame if it's blocked, since it could potentially unblock, and
the entire section is discarded when (goto:) or (undo:) activate. In the case of (output:), we must
pop the stack frame ourselves.
(output:) and (output-value:) block their stack frame, and Section.execute() doesn't pop the stack frame if it's blocked.
Also, if the (output:) was inside an (if:), the containing stack frame of the (if:) isn't popped either.
So, these pops need to be done ourselves.
*/
if (section.stackTop.blocked) {
while (section.stack.length > stackSize) {
section.stack.shift();
}
/*
......
......@@ -716,7 +716,7 @@ define(['jquery', 'macros', 'utils', 'state', 'passages', 'renderer', 'engine',
e.stopPropagation();
Engine.toggleFullscreen();
}
if (alt === "Reload") {
if (alt === "Restart") {
if (State.hasSessionStorage) {
sessionStorage.removeItem("Saved Session");
}
......
......@@ -84,6 +84,10 @@ describe("custom macros", function() {
it("is aliased as (out-data:)", function() {
expect("(set: $e to (macro:[(out-data:'bar')]))($e:)").markupToPrint("bar");
});
it("works inside an (if:)", function() {
expect("(set: $e to (macro:[(if:true)[(output-data:'bar')]]))($e:)").markupToPrint("bar");
expect("(set: $f to (macro:[($e:)(output-data:'bar')]))($f:)").markupToPrint("bar");
});
it("can't be used outside of a custom macro", function() {
expect("(output-data:'baz')").markupToError();
expect("(set: $e to (macro:[(output-data:(output-data:'baz'))]))($e:)").markupToError();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment