public static int FindNextNewLine(ITextSource text, int offset, out string newLineType)
{
if (text == null)
throw new ArgumentNullException("text");
if (offset < 0 || offset > text.TextLength)
throw new ArgumentOutOfRangeException("offset", offset, "offset is outside of text source");
var s = NewLineFinder.NextNewLine(text, offset);
if (s == SimpleSegment.Invalid)
{
newLineType = null;
return -1;
}
if (s.Length == 2)
{
newLineType = "\r\n";
}
else if (text.GetCharAt(s.Offset) == '\n')
{
newLineType = "\n";
}
else
{
newLineType = "\r";
}
return s.Offset;
}