Permalink
Browse files

Updated the outlining tagger to only event over the symmetric differe…

…nce between the old and new outlining regions, instead of the entire buffer.
  • Loading branch information...
1 parent 575d32f commit 1e3fcab586cb97bb859a936d9925a124c79293b6 Noah Richards committed Mar 12, 2010
Showing with 20 additions and 4 deletions.
  1. +20 −4 Outlining/OutliningTagger.cs
View
24 Outlining/OutliningTagger.cs
@@ -53,12 +53,28 @@ void ReparseFile(object sender, EventArgs args)
Span = snapshot.CreateTrackingSpan(t.Span, SpanTrackingMode.EdgeExclusive)
}));
- // For now, just dirty the entire file
+ NormalizedSnapshotSpanCollection oldSectionSpans = new NormalizedSnapshotSpanCollection(
+ _sections.Select(s => s.Span.GetSpan(snapshot)));
+ NormalizedSnapshotSpanCollection newSectionSpans = new NormalizedSnapshotSpanCollection(
+ newSections.Select(s => s.Span.GetSpan(snapshot)));
+
+ NormalizedSnapshotSpanCollection difference = SymmetricDifference(oldSectionSpans, newSectionSpans);
+
_sections = newSections;
- var temp = TagsChanged;
- if (temp != null)
- temp(this, new SnapshotSpanEventArgs(new SnapshotSpan(snapshot, 0, snapshot.Length)));
+ foreach (var span in difference)
+ {
+ var temp = TagsChanged;
+ if (temp != null)
+ temp(this, new SnapshotSpanEventArgs(span));
+ }
+ }
+
+ NormalizedSnapshotSpanCollection SymmetricDifference(NormalizedSnapshotSpanCollection first, NormalizedSnapshotSpanCollection second)
+ {
+ return NormalizedSnapshotSpanCollection.Union(
+ NormalizedSnapshotSpanCollection.Difference(first, second),
+ NormalizedSnapshotSpanCollection.Difference(second, first));
}
public IEnumerable<ITagSpan<IOutliningRegionTag>> GetTags(NormalizedSnapshotSpanCollection spans)

0 comments on commit 1e3fcab

Please sign in to comment.