public ITextSnapshot Insert(int position, string text) { var sb = new StringBuilder(); sb.Append(CurrentSnapshot.GetText(0, position)); sb.Append(text); sb.Append(CurrentSnapshot.GetText(position, CurrentSnapshot.Length - position)); TextChangeMock change = new TextChangeMock(position, 0, String.Empty, text); TextSnapshotMock nextSnapshot = ((TextSnapshotMock)CurrentSnapshot).CreateNextSnapshot(sb.ToString(), change); ApplyChange(nextSnapshot); return(CurrentSnapshot); }
public ITextSnapshot Replace(Span replaceSpan, string replaceWith) { var sb = new StringBuilder(); var oldText = CurrentSnapshot.GetText(replaceSpan); sb.Append(CurrentSnapshot.GetText(0, replaceSpan.Start)); sb.Append(replaceWith); sb.Append(CurrentSnapshot.GetText(replaceSpan.End, CurrentSnapshot.Length - replaceSpan.End)); TextChangeMock change = new TextChangeMock(replaceSpan.Start, replaceSpan.Length, oldText, replaceWith); TextSnapshotMock nextSnapshot = ((TextSnapshotMock)CurrentSnapshot).CreateNextSnapshot(sb.ToString(), change); ApplyChange(nextSnapshot); return(CurrentSnapshot); }
private string GetText() { return CurrentSnapshot.GetText(); }