Browse Source

Add special case for text variation making no change

Now when the textvariation is given an empty block, a vary sequence with no elements, correctly return that there is no variation found.

closes #963

# Conflicts:
#	Assets/Fungus/Docs/CHANGELOG.txt
master
Steve Halliwell 3 years ago
parent
commit
744ba85644
  1. 1
      Assets/Fungus/Docs/CHANGELOG.txt
  2. 9
      Assets/Fungus/Scripts/Utils/TextVariationHandler.cs
  3. 15
      Assets/Tests/Editor/FungusTextVariationSelectionTests.cs

1
Assets/Fungus/Docs/CHANGELOG.txt

@ -12,6 +12,7 @@ Unreleased
## Changed ## Changed
- Block will LogError when an exception is caught from a Command being Executed. - Block will LogError when an exception is caught from a Command being Executed.
- WriterAudio.GetSecondsRemaining reports 0 if not playing. Thanks to KVinS. - 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 v3.13.6
====== ======

9
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; return varyingSections.Count > 0;
} }

15
Assets/Tests/Editor/FungusTextVariationSelectionTests.cs

@ -114,5 +114,20 @@ namespace Fungus.Tests
Assert.Fail(); 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);
}
} }
} }
Loading…
Cancel
Save