Exemple #1
0
 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);
 }
Exemple #2
0
 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());
 }
Exemple #3
0
        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);
        }
Exemple #4
0
 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);
 }
Exemple #5
0
		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);
		}
Exemple #6
0
		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();
		}