tmedwards / sugarcube-2

SugarCube is a free (gratis and libre) story format for Twine/Twee.
https://www.motoslave.net/sugarcube/2/
BSD 2-Clause "Simplified" License
186 stars 42 forks source link

Engine.backward() disables Config.cleanupWikifierOutput = true #240

Open david-donachie opened 1 year ago

david-donachie commented 1 year ago

Describe the bug. Using Engine.backward() in a story with Config.cleanupWikifierOutput = true generates a passage with <br> tags as if Config.cleanupWikifierOutput was not set.

To Reproduce:

  1. Set Config.cleanupWikifierOutput = true in story JS
  2. View a passage
  3. Go to a second passage
  4. Run Engine.backward() to go back to the first pasage

Expected behavior. The first passage should have <p> tags as normal, but just has plain <br> instead

Project details.

david-donachie commented 1 year ago

Related #189

tmedwards commented 1 year ago

This is likely related to timing. I.e., Going backwards before the last moment has finished rendering.

hituro commented 1 year ago

This is likely related to timing. I.e., Going backwards before the last moment has finished rendering.

It seemed to happen even if I waited a long while. Could it be that the engine renders the past moment differently and doesn't load the config setting?

tmedwards commented 1 year ago

Config settings, in general, should be set in either the story JavaScript or StoryInit, which is to say not only outside of the story history but before it even begins. In that case, the setting should always be active during normal operation.

All moments are rendered equally, wrt. the setting anyway.

The cleanup setting is only used if no other Wikifier calls are active somewhere. This is the likely culprit of "it no worky at all" the majority of the time.

hituro commented 1 year ago

Yes, I didn't mean that the Config setting was being reset, I was implying that the rendering process involved in Engine.backward() didn't honour it.

So, given that this happens even if there is a long delay before going backwards, it implies that the process nevertheless invokes another Wikifier? Could it be related to StoryInterface rendering passages?

greyelf commented 1 year ago

I tested the reported behaviour using links like...

<<link 'Backward'>><<run Engine.backward()>><</link>>

...and...

<<link 'Forward'>><<run Engine.forward()>><</link>>

...and the issue also occurs when Engine.forward() is used to wind History forward again.

The Undo and Redo navigation links did not display the reported behaviour when used in the same testing project.