提交 f7a68bc5 编写于 作者: S Sam Harwell

Avoid producing a new tag tree for buffers that aren't part of the SpansToTag

上级 06a9f17a
......@@ -374,6 +374,7 @@ private void CheckSnapshot(ITextSnapshot snapshot)
private ImmutableDictionary<ITextBuffer, TagSpanIntervalTree<TTag>> ConvertToTagTrees(
ImmutableDictionary<ITextBuffer, TagSpanIntervalTree<TTag>> oldTagTrees,
ISet<ITextBuffer> buffersToTag,
ILookup<ITextBuffer, ITagSpan<TTag>> newTagsByBuffer,
IEnumerable<DocumentSnapshotSpan> spansTagged)
{
......@@ -400,6 +401,14 @@ private void CheckSnapshot(ITextSnapshot snapshot)
var newTagTrees = ImmutableDictionary<ITextBuffer, TagSpanIntervalTree<TTag>>.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<TTag> 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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册