Skip to content

Commit

Permalink
Fix throws exception by \color
Browse files Browse the repository at this point in the history
  • Loading branch information
rstm-sf authored and ForNeVeR committed Feb 26, 2020
1 parent c051e6b commit 3dd72b8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/WpfMath.Tests/ParserExceptionTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ let ``"\binom{}" should throw a TexParseException``(): unit =
let ex = assertParseThrows<TexParseException> @"\binom{}"
Assert.Equal("An element is missing", ex.Message)

[<Fact>]
let ``"\color" should throw a TexParseException``(): unit =
let ex = assertParseThrows<TexParseException> @"\color"
Assert.Equal("An element is missing", ex.Message)

[<Fact>]
let ``"\color{red}" should throw a TexParseException``(): unit =
let ex = assertParseThrows<TexParseException> @"\color{red}"
Expand Down
2 changes: 1 addition & 1 deletion src/WpfMath/TexFormulaParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ private static SourceSpan ReadElementGroupOptional(
char closeChar)
{
SkipWhiteSpace(value, ref position);
if (value[position] != openChar)
if (position == value.Length || value[position] != openChar)
return null;

return ReadElementGroup(value, ref position, openChar, closeChar);
Expand Down

0 comments on commit 3dd72b8

Please sign in to comment.