-
Notifications
You must be signed in to change notification settings - Fork 35
/
MarkdownBackgroundParser.cs
34 lines (30 loc) · 1.26 KB
/
MarkdownBackgroundParser.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.VisualStudio.Text;
namespace MarkdownMode
{
internal class MarkdownBackgroundParser : BackgroundParser
{
public MarkdownBackgroundParser(ITextBuffer textBuffer, TaskScheduler taskScheduler, ITextDocumentFactoryService textDocumentFactoryService)
: base(textBuffer, taskScheduler, textDocumentFactoryService)
{
ReparseDelay = TimeSpan.FromMilliseconds(300);
}
protected override void ReParseImpl()
{
ITextSnapshot snapshot = TextBuffer.CurrentSnapshot;
Stopwatch stopwatch = Stopwatch.StartNew();
List<MarkdownSection> sections = new List<MarkdownSection>(
MarkdownParser.ParseMarkdownSections(snapshot)
.Select(t => new MarkdownSection()
{
TokenType = t.TokenType,
Span = snapshot.CreateTrackingSpan(t.Span, SpanTrackingMode.EdgeExclusive)
}));
OnParseComplete(new MarkdownParseResultEventArgs(sections, snapshot, stopwatch.Elapsed));
}
}
}