Created
February 25, 2010 17:41
-
-
Save NoahRic/314798 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void ReparseFile(object sender, EventArgs args) | |
{ | |
ITextSnapshot snapshot = _buffer.CurrentSnapshot; | |
List<MarkdownSection> newSections = new List<MarkdownSection>( | |
MarkdownParser.ParseMarkdownSections(snapshot) | |
.Select(t => new MarkdownSection() | |
{ | |
TokenType = t.TokenType, | |
Span = snapshot.CreateTrackingSpan(t.Span, SpanTrackingMode.EdgeExclusive) | |
})); | |
NormalizedSnapshotSpanCollection oldSectionSpans = new NormalizedSnapshotSpanCollection( | |
_sections.Select(s => s.Span.GetSpan(snapshot))); | |
NormalizedSnapshotSpanCollection newSectionSpans = new NormalizedSnapshotSpanCollection( | |
newSections.Select(s => s.Span.GetSpan(snapshot))); | |
NormalizedSnapshotSpanCollection difference = NormalizedSnapshotSpanCollection.Difference(oldSectionSpans, newSectionSpans); | |
_sections = newSections; | |
var temp = TagsChanged; | |
if (temp != null && difference.Count > 0) | |
{ | |
temp(this, new SnapshotSpanEventArgs(new SnapshotSpan(difference[0].Start, difference[difference.Count - 1].End))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment