Fix: translation id makes a shortcode event swallow the following lines - #2802
Open
ajveach wants to merge 1 commit into
Open
Fix: translation id makes a shortcode event swallow the following lines#2802ajveach wants to merge 1 commit into
ajveach wants to merge 1 commit into
Conversation
is_string_full_event() treats a shortcode event as complete only when the string ends with ']', but _store_as_string() appends the translation id *after* the closing bracket. So a bracketed event carrying an id — for example [text_input text="What is your name?" var="name"] #id:11 — never reads as complete, and the collect loop in DialogicTimeline.process() keeps appending the following lines into it until it reaches one that does end with ']'. Those lines are absorbed into the first event and never become events of their own. At runtime this looks like dialogue and events silently going missing, with no error and nothing wrong in the timeline text. Text events are unaffected because they return true unconditionally, so it only appears once translation is enabled and ids start being written onto bracketed events. is_string_full_event() now removes a trailing #id: before testing for the bracket, the same way _load_from_string() and _test_event_string() already do for the same suffix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
With translation enabled, any bracketed event that carries a translation id
silently absorbs the lines after it. Those lines never become events — they
just disappear at runtime, with no error and nothing visibly wrong in the
timeline text.
Reproduction
With
translation/enabledon, a timeline saved as:parses to a single
text_inputevent. Both text lines are gone.If a later line does end with
], the swallowing stops there — and thatevent is consumed as well, so a bracketed event following the affected one
is lost along with the lines between them.
Cause
DialogicEvent.is_string_full_event()treats a shortcode event as completeonly when the string ends with
']':but
_store_as_string()appends the translation id after the closingbracket:
So the event never reads as complete, and the collect loop in
DialogicTimeline.process()—while not event.is_string_full_event(event_content)— keeps appendingfollowing lines into it until one ends with
']'.Text events are unaffected, because they return
trueunconditionally. Thatis why this only shows up once translation is enabled and ids begin to be
written onto bracketed events.
The fix
is_string_full_event()now strips a trailing#id:before testing for thebracket, the same way
_load_from_string()and_test_event_string()already do for the same suffix.
The strip is gated on
can_be_translated(), matching_store_as_string()—an id is only ever written under that condition, so no event that carries one
can be missed, and no event that lacks one changes behaviour.