Skip to content

Commit

Permalink
Change order of when tags are added to choice content so they don’t c…
Browse files Browse the repository at this point in the history
…ome after a terminating newline or divert
  • Loading branch information
joethephish committed Jun 24, 2017
1 parent 43e2d80 commit 1c3308a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
17 changes: 7 additions & 10 deletions inklecate/InkParser/InkParser_Choices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ protected Choice Choice()
Warning ("Choice is completely empty. Interpretting as a default fallback choice. Add a divert arrow to remove this warning: * ->");

if (!innerContent) innerContent = new ContentList ();

var tags = Parse (Tags);
if (tags != null) {
innerContent.AddContent(tags);
}

innerContent.AddContent (new Text ("\n"));

// Normal diverts on the end of a choice - simply add to the normal content
Expand All @@ -102,16 +108,7 @@ protected Choice Choice()
}
}

var tags = Parse (Tags);
if (tags != null) {
if (hasWeaveStyleInlineBrackets) {
//if (!innerContent)
// innerContent = new ContentList();
innerContent.AddContent(tags);
} else {
startContent.AddContent (tags);
}
}


var choice = new Choice (startContent, optionOnlyContent, innerContent);
choice.name = optionalName;
Expand Down
22 changes: 22 additions & 0 deletions tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2936,6 +2936,28 @@ public void TestDivertTargetsWithParameters ()
Assert.AreEqual ("5\n", story.ContinueMaximally ());
}

[Test ()]
public void TestTagOnChoice ()
{
var storyStr =
@"
* [Hi] Hello -> END #hey
";

var story = CompileString (storyStr);

story.Continue ();

story.ChooseChoiceIndex (0);

var txt = story.Continue ();
var tags = story.currentTags;

Assert.AreEqual (" Hello\n", txt); // argh need to fix space?
Assert.AreEqual (1, tags.Count);
Assert.AreEqual ("hey", tags[0]);
}

// Helper compile function
protected Story CompileString(string str, bool countAllVisits = false, bool testingErrors = false)
{
Expand Down

0 comments on commit 1c3308a

Please sign in to comment.