If SynEdit has not got a handle yet, it will scan in the background (on idle in small steps).
This is useful if you have many SynEdit, like the IDE does. Then at startup, you do not need to wait for all highlighters to finish. (see TCustomSynEdit.IdleScanRanges line 4890 in SynEdit.pp)
Any visible SynEdit will scan all (in future maybe: to the last visible line).
Before a SynEdit interacts with a highlighter it always does:
FHighlighter.CurrentLines := FLines;
Then it calls:
FHighlighter.ScanRanges;
This will scan all lines, that have changed since the last scan.
ScanRanges will only return if all is done.
The highlighter attaches a "ranges" object to the lines. The lines will inform the ranges about changes.
See TSynHighlighterRangeList NeedsReScanStartIndex / NeedsReScanEndIndex
TSynHighlighterRangeList = class(TSynManagedStorageMem)
procedure ClearReScanNeeded;
procedure AdjustReScanStart(ANewStart: Integer);
procedure InvalidateAll;
property NeedsReScanStartIndex: Integer read FNeedsReScanStartIndex;
property NeedsReScanEndIndex: Integer read FNeedsReScanEndIndex;
property NeedsReScanRealStartIndex: Integer read GetNeedsReScanRealStartIndex;
end;
The highlighter may continue past NeedsReScanEndIndex, as long as the new "range" value for a line differs from the stored one. (See the highlighter tutorial on the wiki)
From memory/not tested, to force a full rescan (must probably subclass synedit)
FHighlighter.CurrentLines := FLines;
FHighlighter.CurrentRanges.InvalidateAll;
FHighlighter.ScanRanges;