private static TextSpan GetAdjustedTextSpan(TextSpan span, string?text, NewLineMode newLineMode, bool addOffset = false) { if (newLineMode != NewLineMode.Crlf || text is null) { return(span); } if (addOffset) { text = text.Replace("\r\n", "\r"); } int startOffset = text.Take(span.Start).Count(c => c == '\r'); int endOffset = text.Take(span.End).Count(c => c == '\r'); return(TextSpan.FromBounds(span.Start + (addOffset ? +startOffset : -startOffset), span.End + (addOffset ? +endOffset : -endOffset))); }
private static TextGetOptions TextGetOptionsFromNewLineMode(NewLineMode newLineMode) => newLineMode switch {