void CreateNewCurrentSnapshot(IList <ITextChange> changes, int?reiteratedVersionNumber = null, ITextSource afterTextSource = null) { // It's null the first time it's called from the ctor if (changes != null) { currentTextVersion = currentTextVersion.SetChanges(changes, reiteratedVersionNumber); } CurrentSnapshot = new TextSnapshot(afterTextSource ?? Document.CreateSnapshot(), ContentType, this, currentTextVersion); }
internal bool IsSafeToAccessDocumentFromSnapshot(TextSnapshot snapshot) { // If it's not the latest snapshot, Document could be different if (snapshot != CurrentSnapshot) { return(false); } // It's only safe to access Document on the owner thread. If owner thread // is null, assume there's only one thread that accesses the text buffer. return(CheckAccess()); }
void CreateNewCurrentSnapshot(IList <ITextChange>?changes, int?reiteratedVersionNumber = null, ITextSource?afterTextSource = null) { // It's null the first time it's called from the ctor if (changes is not null) { currentTextVersion = currentTextVersion.SetChanges(changes, reiteratedVersionNumber); } var textSource = afterTextSource ?? Document.CreateSnapshot(); var textImage = new TextImage(this, textSource, currentTextVersion.ImageVersion); CurrentSnapshot = new TextSnapshot(textImage, ContentType, this, currentTextVersion); }
public bool Replace(Span replaceSpan, string replaceWith) { if (Canceled || hasApplied) { throw new InvalidOperationException(); } if (replaceSpan.End > TextSnapshot.Length) { throw new ArgumentOutOfRangeException(nameof(replaceSpan)); } if (replaceSpan.Length == 0 && replaceWith.Length == 0) { return(true); } changes.Add(new TextChange(replaceSpan.Start, TextSnapshot.GetText(replaceSpan), replaceWith)); return(true); }
void CreateNewCurrentSnapshot(IList<ITextChange> changes, int? reiteratedVersionNumber = null, ITextSource afterTextSource = null) { // It's null the first time it's called from the ctor if (changes != null) currentTextVersion = currentTextVersion.SetChanges(changes, reiteratedVersionNumber); CurrentSnapshot = new TextSnapshot(afterTextSource ?? Document.CreateSnapshot(), ContentType, this, currentTextVersion); }
internal bool IsSafeToAccessDocumentFromSnapshot(TextSnapshot snapshot) { // If it's not the latest snapshot, Document could be different if (snapshot != CurrentSnapshot) return false; // It's only safe to access Document on the owner thread. If owner thread // is null, assume there's only one thread that accesses the text buffer. return CheckAccess(); }