From f7a68bc5f4e27e8693fa9c89c5ec69c26acb6130 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Tue, 19 Jun 2018 17:01:07 -0500 Subject: [PATCH] Avoid producing a new tag tree for buffers that aren't part of the SpansToTag --- ...synchronousTaggerProvider.TagSource_ProduceTags.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/EditorFeatures/Core/Tagging/AbstractAsynchronousTaggerProvider.TagSource_ProduceTags.cs b/src/EditorFeatures/Core/Tagging/AbstractAsynchronousTaggerProvider.TagSource_ProduceTags.cs index 1797f9d1379..0e841e1586f 100644 --- a/src/EditorFeatures/Core/Tagging/AbstractAsynchronousTaggerProvider.TagSource_ProduceTags.cs +++ b/src/EditorFeatures/Core/Tagging/AbstractAsynchronousTaggerProvider.TagSource_ProduceTags.cs @@ -374,6 +374,7 @@ private void CheckSnapshot(ITextSnapshot snapshot) private ImmutableDictionary> ConvertToTagTrees( ImmutableDictionary> oldTagTrees, + ISet buffersToTag, ILookup> newTagsByBuffer, IEnumerable spansTagged) { @@ -400,6 +401,14 @@ private void CheckSnapshot(ITextSnapshot snapshot) var newTagTrees = ImmutableDictionary>.Empty; foreach (var buffer in buffers) { + if (!buffersToTag.Contains(buffer)) + { + // Avoid computing a new tag tree for a buffer not requested for tagging. This handles cases + // where oldTagTrees contains tags for a buffer that was removed from the buffers of interest, + // and also cases where one or more taggers produced tags outside the requested context. + continue; + } + var newTagTree = ComputeNewTagTree(oldTagTrees, buffer, newTagsByBuffer[buffer], spansToInvalidateByBuffer[buffer]); if (newTagTree != null) { @@ -627,7 +636,7 @@ private void ProduceTagsSynchronously(TaggerContext context) var newTagsByBuffer = context.tagSpans.Where(ts => buffersToTag.Contains(ts.Span.Snapshot.TextBuffer)) .ToLookup(t => t.Span.Snapshot.TextBuffer); - var newTagTrees = ConvertToTagTrees(oldTagTrees, newTagsByBuffer, context._spansTagged); + var newTagTrees = ConvertToTagTrees(oldTagTrees, buffersToTag, newTagsByBuffer, context._spansTagged); ProcessNewTagTrees( context.SpansToTag, oldTagTrees, newTagTrees, context.State, initialTags, context.CancellationToken); -- GitLab