public TextBufferMock(string content, string contentTypeName) { ContentType = new ContentTypeMock(contentTypeName, new IContentType[] { ContentTypeMock.TextContentType }); TextVersionMock initialVersion = new TextVersionMock(this, 0, content.Length); CurrentSnapshot = new TextSnapshotMock(content, this, initialVersion); }
public TextSnapshotMock CreateNextSnapshot(string content, TextChangeMock change) { Change = change; TextVersionMock nextVersion = _version.CreateNextVersion(change); TextSnapshotMock nextSnapshot = new TextSnapshotMock(content, TextBuffer, nextVersion); return nextSnapshot; }
public TextSnapshotMock CreateNextSnapshot(string content, TextChangeMock change) { Change = change; TextVersionMock nextVersion = _version.CreateNextVersion(change); TextSnapshotMock nextSnapshot = new TextSnapshotMock(content, TextBuffer, nextVersion); return(nextSnapshot); }
public ITextSnapshot Delete(Span deleteSpan) { var sb = new StringBuilder(); var oldText = CurrentSnapshot.GetText(deleteSpan.Start, deleteSpan.Length); sb.Append(CurrentSnapshot.GetText(0, deleteSpan.Start)); sb.Append(CurrentSnapshot.GetText(deleteSpan.End, CurrentSnapshot.Length - deleteSpan.End)); TextChangeMock change = new TextChangeMock(deleteSpan.Start, deleteSpan.Length, oldText, String.Empty); TextSnapshotMock nextSnapshot = ((TextSnapshotMock)CurrentSnapshot).CreateNextSnapshot(sb.ToString(), change); ApplyChange(nextSnapshot); return(CurrentSnapshot); }
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); }
private void ApplyChange(TextSnapshotMock snapshot) { Changing?.Invoke(this, new TextContentChangingEventArgs(CurrentSnapshot, new object(), CancelAction)); var before = CurrentSnapshot; CurrentSnapshot = snapshot; var args = new TextContentChangedEventArgs(before, CurrentSnapshot, EditOptions.None, new object()); BeforeChanged?.Invoke(this, args); ChangedHighPriority?.Invoke(this, args); Changed?.Invoke(this, args); ChangedLowPriority?.Invoke(this, args); PostChanged?.Invoke(this, EventArgs.Empty); }
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 void ApplyChange(TextSnapshotMock snapshot) { if (Changing != null) { Changing(this, new TextContentChangingEventArgs(CurrentSnapshot, new object(), CancelAction)); } var before = CurrentSnapshot; CurrentSnapshot = snapshot; var args = new TextContentChangedEventArgs(before, CurrentSnapshot, EditOptions.None, new object()); if (BeforeChanged != null) { BeforeChanged(this, args); } if (ChangedHighPriority != null) { ChangedHighPriority(this, args); } if (Changed != null) { Changed(this, args); } if (ChangedLowPriority != null) { ChangedLowPriority(this, args); } if (PostChanged != null) { PostChanged(this, EventArgs.Empty); } }
private void ApplyChange(TextSnapshotMock snapshot) { if (Changing != null) Changing(this, new TextContentChangingEventArgs(CurrentSnapshot, new object(), CancelAction)); var before = CurrentSnapshot; CurrentSnapshot = snapshot; var args = new TextContentChangedEventArgs(before, CurrentSnapshot, EditOptions.None, new object()); if (BeforeChanged != null) BeforeChanged(this, args); if (ChangedHighPriority != null) ChangedHighPriority(this, args); if (Changed != null) Changed(this, args); if (ChangedLowPriority != null) ChangedLowPriority(this, args); if (PostChanged != null) PostChanged(this, EventArgs.Empty); }