Invalidating styling information when SCI_SETILEXER is called

23 views
Skip to first unread message

Mitchell

unread,
Aug 18, 2022, 6:35:08 PM8/18/22
to scintilla...@googlegroups.com
Hi,

I am setting a lexer via SCI_SETILEXER, but all of my document's styling information still exists. I have to call one of SCI_COLOURISE, SCI_SETKEYWORDS, SCI_SETPROPERTY, etc. in order to trigger re-lexing. Is there a reason why SCI_SETILEXER does not immediately invalidate all styling information? Or maybe I'm missing something?

Cheers,
Mitchell

Neil Hodgson

unread,
Aug 19, 2022, 9:58:28 PM8/19/22
to Scintilla mailing list
Mitchell:

> I am setting a lexer via SCI_SETILEXER, but all of my document's styling information still exists. I have to call one of SCI_COLOURISE, SCI_SETKEYWORDS, SCI_SETPROPERTY, etc. in order to trigger re-lexing. Is there a reason why SCI_SETILEXER does not immediately invalidate all styling information?

Back on 4.x, SCI_SETLEXER and SCI_SETLEXERLANGUAGE would have no effect if called with the same language as already set. Existing applications often reevaluate configuration and call APIs with the same value as before so Scintilla has some code to detect changes and avoid work for null updates. SCI_SETILEXER has a different concept of lexer identity with each call to create a lexer returning a new ILexer*. If each call to SCI_SETILEXER cleared out styling then they would be much more expensive for effectively null updates and existing applications would show worse performance when updated to 5.x.

Its easier for applications to restart lexing after a reset that they think is significant than to preserve styling for insignificant updates so SCI_SETILEXER was implemented to preserve current styling.

Neil

Reply all
Reply to author
Forward
0 new messages