public virtual int IndentLine(TextDocument document, DocumentLine line, int caretOffset)
{
if (document == null)
throw new ArgumentNullException("document");
if (line == null)
throw new ArgumentNullException("line");
var previousLine = line.PreviousLine;
if (previousLine != null)
{
var indentationSegment = TextUtilities.GetWhitespaceAfter(document, previousLine.Offset);
var indentation = document.GetText(indentationSegment);
// copy indentation to line
indentationSegment = TextUtilities.GetWhitespaceAfter(document, line.Offset);
document.Replace(indentationSegment, indentation);
}
return caretOffset;
}