[Lazarus] About 0013268: SynEdit parses every line twice on load or paste (Attn: Flávio)

Martin Friebe lazarus at mfriebe.de
Thu Mar 5 12:09:55 CET 2009


Hans-Peter Diettrich wrote:
> Flávio Etrusco schrieb:
>
>   
>> Calling BeginUpdate is not enough, they must disable/unset the
>> highlighter to avoid the double parse.
>>     
>
> I found it sufficient when the highlighter only parses the current 
> line(s) while painting the text. When the highlighter information is 
> reduced to a flag, indicating continuation lines in multi-line comments, 
> this flag can be stored together with the informaton about the line 
> begin in the text (line number table). Then the determination of the 
> line positions can be done by the highlighter/parser base class. Later, 
> when text is displayed, the continuation flag of the current line is 
> passed to the highlighter, so that only the requested line has to be parsed.
>
> Things can become more complicated, of course, when e.g. matching pairs 
> (begin-end, parentheses...) shall be highlighted dynamically.
>
>   

The SynHighlighterPas unfortenately needs to keep some state across 
lines => some of this is needed for folding.

You can fold on a procedure, except if it is in:
- interface (just the declaration)
- "type" declaration: "a = procedure of object"
There are many many other examples like this....

This may only be known if you know the state of the previous line(s). 
Actually in the worst case that can be a 100 lines above, if someone put 
as many empty, or comment lines in between.

Yet I agree, the highlighter shouldn't scan on every change, it should 
scan only if the info is required => When a line is painted, all 
unscanned lines to this line must be scanned.
That's a different issue from what we currently discuss.
But it is also not that simple, because folding relies on highlighting. 
If the vertical scrollbar is painted, then all folding info down to the 
end of file is needed (to calculate the amount of actual visible lines). 
I have ideas how to still reduce scanning, but one step at a time......


Best Regards
Martin




More information about the Lazarus mailing list