Commit 84f340df authored by Leon Arnott's avatar Leon Arnott
Browse files

Fixed two more bugs.

 * Fixed a bug where custom macros stored in story-wide variables wouldn't be preserved when reloading the page in the browser (restoring the game state using session storage) and would instead become erroneous data.
 * Fixed a bug where (input-box:) crashed upon the first inputted character if you didn't supply the optional bound variable.

Closes #219. Closes #220.
parent 5d1c80c5f9c9
......@@ -6,6 +6,7 @@ Documentation is at http://twine2.neocities.org/. See below for compilation inst
#### Bugfixes
* Fixed a bug where custom macros stored in story-wide variables wouldn't be preserved when reloading the page in the browser (restoring the game state using session storage) and would instead become erroneous data.
* Fixed a long-standing bug where line breaks couldn't be used as whitespace around operators. For instance, `(print: 2`, a line break, then `is > 1)` would cause an error instead of being treated as `(print: 2 is > 1)`.
* Fixed a long-standing bug where combined changers weren't being properly copied, and adding more changers to them would mutate variables that were storing that changer.
* 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`).
......@@ -14,6 +15,7 @@ Documentation is at http://twine2.neocities.org/. See below for compilation inst
* 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.
* Fixed a bug where, upon supplying a label string to `(meter:)`, any updates to the meter would cause that label to gain any styles, such as `(border:)` borders, that had been given to the meter itself.
* Fixed a bug where `(input-box:)` crashed upon the first inputted character if you didn't supply the optional bound variable.
### 3.2.1 changes (Jan 18, 2021):
......
......@@ -20,10 +20,10 @@ require.config({
'jqueryplugins',
],
});
require(['jquery', 'debugmode/mode', 'renderer', 'state', 'section', 'engine', 'passages', 'utils', 'utils/renderutils', 'internaltypes/twineerror', 'macros',
require(['jquery', 'debugmode/mode', 'renderer', 'state', 'section', 'engine', 'passages', 'utils', 'utils/renderutils', 'internaltypes/varscope', 'internaltypes/twineerror', 'macros',
'macrolib/values', 'macrolib/commands', 'macrolib/datastructures', 'macrolib/stylechangers', 'macrolib/enchantments', 'macrolib/metadata', 'macrolib/patterns',
'macrolib/links', 'macrolib/custommacros', 'repl'],
($, DebugMode, Renderer, State, Section, Engine, Passages, Utils, {dialog}, TwineError) => {
($, DebugMode, Renderer, State, Section, Engine, Passages, Utils, VarScope, {dialog}, TwineError) => {
/*
Harlowe, the default story format for Twine 2.
......@@ -181,6 +181,12 @@ require(['jquery', 'debugmode/mode', 'renderer', 'state', 'section', 'engine', '
// Set up the passage metadata
const tempSection = Section.create();
/*
This is necessary in order for State to recompile custom macros containing typed variables as parameters.
These are recompiled into VarRefs, even though they aren't actually references to temp variables, but definitions.
*/
tempSection.stack = [{tempVariables:Object.create(VarScope)}];
const metadataErrors = Passages.loadMetadata(tempSection);
if (metadataErrors.length) {
const d = dialog({
......
......@@ -2018,7 +2018,7 @@ define(['jquery', 'macros', 'utils', 'state', 'passages', 'renderer', 'engine',
/*
The (force-input-box:) version of this event is further below.
*/
if (!force) {
if (!force && bind) {
cd.data.inputBoxEvent = (textarea) => {
const value = textarea.val();
const result = bind.set(value);
......
......@@ -405,8 +405,9 @@ define(['utils/naturalsort','utils', 'internaltypes/twineerror', 'patterns'],
This should never receive a TwineError.
*/
function toSource(obj, isProperty) {
if (TwineError.containsError(obj)) {
impossible("toSource","received a TwineError");
let e = TwineError.containsError(obj);
if (e) {
impossible("toSource","received a TwineError: " + e.message);
}
if (typeof obj.TwineScript_ToSource === sFunction) {
return obj.TwineScript_ToSource();
......
......@@ -412,6 +412,12 @@ describe("interface macros", function(){
expect(p).toMatch(/display:\s*block/);
});
});
it("doesn't error when the <textarea> is edited", function() {
var t = runPassage("("+name+":\"XXX===\",3,'Foo')").find('textarea');
expect(function() {
t.val('Bar').trigger('input');
}).not.toThrow();
});
if (!force) {
it("if bound, sets the bound variable when the <textarea> is edited", function() {
['bind','2bind'].forEach(function(e) {
......
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