/// <inheritdoc/>
 public virtual void IndentLine(TextDocument document, DocumentLine line)
 {
     if (document == null)
         throw new ArgumentNullException("document");
     if (line == null)
         throw new ArgumentNullException("line");
     DocumentLine previousLine = line.PreviousLine;
     if (previousLine != null) {
         ISegment indentationSegment = TextUtilities.GetWhitespaceAfter(document, previousLine.Offset);
         string indentation = document.GetText(indentationSegment);
         // copy indentation to line
         indentationSegment = TextUtilities.GetWhitespaceAfter(document, line.Offset);
         document.Replace(indentationSegment, indentation);
     }
 }
示例#2
0
 /// <summary>
 /// Gets the newline sequence used in the document at the specified line.
 /// </summary>
 public static string GetNewLineFromDocument(TextDocument document, int lineNumber)
 {
     DocumentLine line = document.GetLineByNumber(lineNumber);
     if (line.DelimiterLength == 0) {
         // at the end of the document, there's no line delimiter, so use the delimiter
         // from the previous line
         line = line.PreviousLine;
         if (line == null)
             return Environment.NewLine;
     }
     return document.GetText(line.Offset + line.Length, line.DelimiterLength);
 }