fix: slice from initial index

This commit is contained in:
Oliver Booth 2023-08-08 22:25:23 +01:00
parent 030e5fdd3d
commit 6743918f44
Signed by: oliverbooth
GPG Key ID: 725DB725A0D9EE61

View File

@ -1,4 +1,4 @@
using Cysharp.Text; using Cysharp.Text;
using Markdig.Helpers; using Markdig.Helpers;
using Markdig.Parsers; using Markdig.Parsers;
@ -104,6 +104,8 @@ public sealed class TemplateInlineParser : InlineParser
out bool hasValue) out bool hasValue)
{ {
var isEscaped = false; var isEscaped = false;
int startIndex = index;
for (; index < argumentSpan.Length; index++) for (; index < argumentSpan.Length; index++)
{ {
char currentChar = argumentSpan[index]; char currentChar = argumentSpan[index];
@ -119,16 +121,16 @@ public sealed class TemplateInlineParser : InlineParser
case '|' when !isEscaped: case '|' when !isEscaped:
hasValue = false; hasValue = false;
return argumentSpan[..index]; return argumentSpan[startIndex..index];
case '=' when !isEscaped && !consumeToken: case '=' when !isEscaped && !consumeToken:
hasValue = true; hasValue = true;
return argumentSpan[..index]; return argumentSpan[startIndex..index];
} }
} }
hasValue = false; hasValue = false;
return argumentSpan[..index]; return argumentSpan[startIndex..index];
} }
private static ReadOnlySpan<char> ReadUntilClosure(ReadOnlySpan<char> input) private static ReadOnlySpan<char> ReadUntilClosure(ReadOnlySpan<char> input)