diff --git a/Assets/Fungus/Docs/CHANGELOG.txt b/Assets/Fungus/Docs/CHANGELOG.txt index 7470c41e..37530ca3 100644 --- a/Assets/Fungus/Docs/CHANGELOG.txt +++ b/Assets/Fungus/Docs/CHANGELOG.txt @@ -12,6 +12,7 @@ Unreleased ## Changed - Block will LogError when an exception is caught from a Command being Executed. - WriterAudio.GetSecondsRemaining reports 0 if not playing. Thanks to KVinS. + - Add special case that skips variation logic for sequences that contains no elements, making no change. v3.13.6 ====== diff --git a/Assets/Fungus/Scripts/Utils/TextVariationHandler.cs b/Assets/Fungus/Scripts/Utils/TextVariationHandler.cs index 5c2111f8..15b341b9 100644 --- a/Assets/Fungus/Scripts/Utils/TextVariationHandler.cs +++ b/Assets/Fungus/Scripts/Utils/TextVariationHandler.cs @@ -168,6 +168,15 @@ namespace Fungus } } + // As per issue #963 this should just return as if no variation + if(varyingSections.Count == 1) + { + if (varyingSections[0].type == Section.VaryType.Sequence && + varyingSections[0].elements.Count == 0) + return false; + } + + return varyingSections.Count > 0; } diff --git a/Assets/Tests/Editor/FungusTextVariationSelectionTests.cs b/Assets/Tests/Editor/FungusTextVariationSelectionTests.cs index 64d2937f..28e15616 100644 --- a/Assets/Tests/Editor/FungusTextVariationSelectionTests.cs +++ b/Assets/Tests/Editor/FungusTextVariationSelectionTests.cs @@ -114,5 +114,20 @@ namespace Fungus.Tests Assert.Fail(); } } + + [Test] + public void SquareBracketsWithoutTypeNoImpact() + { + Fungus.TextVariationHandler.ClearHistory(); + + string startingText = @"This is test a [of changing nothing]"; + const string expected = @"This is test a [of changing nothing]"; + + string res = string.Empty; + + res = Fungus.TextVariationHandler.SelectVariations(startingText); + + Assert.AreEqual(expected, res); + } } } \ No newline at end of file