When your Source
object is initialized, it starts off with a LastParseTime
of Int32.MaxValue
. The code that causes fires off a ParseRequest
with ParseReason.Check
checks the LastParseTime
value to see if the time since the last change to the text is less than the time it takes to run a parse (or the CodeSenseDelay
setting, whichever is greater).
The code that handles the response from ParseSource
is supposed to set the LastParseTime
, but as far as I can tell, it only does that if the ParseReason
is Check
.
You can get around this issue by setting Source.LastParseTime = 0
when you initialize your Source
. This has the side-effect of setting CompletedFirstParse
to true
, even if the first parse hasn't finished yet.
Another way to fix this issue is to override Source.OnIdle
to fire off the first call to BeginParse()
This is the way I would recommend.
public override void OnIdle(bool periodic)
{
// Once first "Check" parse completes, revert to base implementation
if (this.CompletedFirstParse)
{
base.OnIdle(periodic);
}
// Same as base implementation, except we don't check lastParseTime
else if (!periodic || this.LanguageService == null || this.LanguageService.LastActiveTextView == null || (this.IsCompletorActive) || (!this.IsDirty || this.LanguageService.IsParsing))
{
this.BeginParse();
}
}