private void NotifyEditors(NormalizedSnapshotSpanCollection changes, TaggerDelay delay)
            {
                _tagSource.AssertIsForeground();

                if (changes.Count == 0)
                {
                    // nothing to do.
                    return;
                }

                if (delay == TaggerDelay.NearImmediate)
                {
                    // if delay is immediate, we let notifier knows about the change right away
                    _batchChangeNotifier.EnqueueChanges(changes);
                    return;
                }

                // if delay is anything more than that, we let notifier knows about the change after given delay
                // event notification is only cancellable when disposing of the tagger.
                _tagSource.RegisterNotification(
                    () => _batchChangeNotifier.EnqueueChanges(changes),
                    (int)delay.ComputeTimeDelay(_subjectBuffer).TotalMilliseconds,
                    _cancellationTokenSource.Token
                    );
            }
Exemple #2
0
            private void OnTagsChangedForBuffer(ICollection <KeyValuePair <ITextBuffer, NormalizedSnapshotSpanCollection> > changes)
            {
                _tagSource.AssertIsForeground();

                // Note: This operation is uncancellable. Once we've been notified here, our cached tags
                // in the tag source are new. If we don't update the UI of the editor then we will end
                // up in an inconsistent state between us and the editor where we have new tags but the
                // editor will never know.

                foreach (var change in changes)
                {
                    if (change.Key != _subjectBuffer)
                    {
                        continue;
                    }

                    // Now report them back to the UI on the main thread.
                    _batchChangeNotifier.EnqueueChanges(change.Value);
                }
            }