Пример #1
0
        public bool ApplyChanges(ITextEdit textEdit, FormatLinesResult result)
        {
            var lineEnding = DetectLineEnding(textEdit.Snapshot);

            var sb     = new StringBuilder();
            var indent = new string(' ', result.Indent);

            foreach (var line in result.Lines)
            {
                if (sb.Length > 0)
                {
                    sb.Append(lineEnding);
                }
                sb.Append(indent);
                sb.Append(result.CommentType.TextPrefix);
                sb.Append(line);
            }
            var commentText = sb.ToString();
            var oldSpan     = result.SnapshotSpan.Span;
            var oldText     = textEdit.Snapshot.GetText(oldSpan);

            if (oldText == commentText)
            {
                return(false);
            }

            textEdit.Replace(oldSpan, commentText);
            return(true);
        }
Пример #2
0
    public bool ApplyChanges(ITextEdit textEdit, FormatLinesResult result) {
      var lineEnding = DetectLineEnding(textEdit.Snapshot);

      var sb = new StringBuilder();
      var indent = new string(' ', result.Indent);
      foreach (var line in result.Lines) {
        if (sb.Length > 0)
          sb.Append(lineEnding);
        sb.Append(indent);
        sb.Append(result.CommentType.TextPrefix);
        sb.Append(line);
      }
      var commentText = sb.ToString();
      var oldSpan = result.SnapshotSpan.Span;
      var oldText = textEdit.Snapshot.GetText(oldSpan);
      if (oldText == commentText)
        return false;

      textEdit.Replace(oldSpan, commentText);
      return true;
    }
 private static void GenerateAsserts(FormatLinesResult formatLines)
 {
     Trace.WriteLine(string.Format("Assert.AreEqual({0}, formatLines.Indent);", formatLines.Indent));
       Trace.WriteLine(string.Format("Assert.AreEqual({0}, formatLines.Lines.Count);", formatLines.Lines.Count));
       int lineNumber = 0;
       foreach (var line in formatLines.Lines) {
     Trace.WriteLine(string.Format("Assert.AreEqual(\"{0}\", formatLines.Lines[{1}]);", line, lineNumber));
     lineNumber++;
       }
 }