inkjs icon indicating copy to clipboard operation
inkjs copied to clipboard

Dynamic Tags are generated in reverse order

Open isyourguy opened this issue 11 months ago • 1 comments

Describe the bug

Using Dynamic Tags inside Choices causes the Tag string to be generated in reverse order. (i.e. #tag {var1}{var2} becomes var2var1tag )

To Reproduce

Create a Dynamic Tag inside of a choice. (i.e. +[choice #tag {var1}{var2}]

Expected behavior

The Tag string should be generated in the correct order.

Environment

  • OS: Windows
  • Web browser version: Firefox 123
  • inkjs version: 2.2.2

Additional context

In Ink, Dynamic Tags are generated by iterating over a stack, namely contentStackForTag in Story.cs. Because the output stream is iterated over in reverse order this makes sense, as the first element pushed to the stack is the last element removed. This same variable in inkjs is an array, and thus when iterated over, the last element pushed to the array is also the last that is appended to the string.

isyourguy avatar Mar 20 '24 18:03 isyourguy

Thanks for the report !

smwhr avatar Mar 21 '24 06:03 smwhr

Fixed in next release 2.2.3

smwhr avatar May 14 '24 15:05 smwhr