Fixes Source Text length being off by the length of a newline

This commit is contained in:
Deukhoofd 2018-11-25 21:18:58 +01:00
parent 5f9c32874a
commit d4fc24b389
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
1 changed files with 3 additions and 3 deletions

View File

@ -10,14 +10,14 @@ namespace Upsilon.Text
public SourceText(string text)
{
_text = text;
var lines = text.Split('\n');
var lines = text.Split(new[] {Environment.NewLine}, StringSplitOptions.None);
_lines = new SourceTextLine[lines.Length];
var linePos = 0;
for (var index = 0; index < lines.Length; index++)
{
var line = lines[index];
_lines[index] = new SourceTextLine(linePos, line.Length);
linePos += line.Length;
_lines[index] = new SourceTextLine(linePos, line.Length + Environment.NewLine.Length);
linePos += line.Length + Environment.NewLine.Length;
}
}