When filetype is changed to a compatible filetype (such as C->C++ and then possibly back to C), colorization is lost. It seems that with Scintilla 5, when language-specific highlighting changes, SCI_SETKEYWORDS has to be called again to take effect.
By setting keyword_hash to 0 we force Geany to call sci_set_keywords() in document_highlight_tags() which fixes the problem.
Fixes #3550 You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/3553
-- Commit Summary --
* Fix keyword colorization on filetype change
-- File Changes --
M src/document.c (3)
-- Patch Links --
https://github.com/geany/geany/pull/3553.patch https://github.com/geany/geany/pull/3553.diff
Have you checked if this is perhaps a bug in scintilla and maybe fixed by #3551?
See also analysis [here](https://github.com/geany/geany/issues/3550#issuecomment-1713029625)
I read that but it's not clear to me how that explains the change here. You talk about a failed parser but that is not talked about here. So I assumed @techee came to a different conclusion.
@kugel- When you posted a suggestion about possible cause/fix here on the pull request, not the issue #3550 where the discussion had happened, it was not clear that you had seen that discussion, so I posted a cross reference to be helpful.
The cross referenced post actually agrees with @techee as to the cause and adds detail of the underlying triggers for the bug based on my analysis, so yes it says things not mentioned by @techee. But it is not disagreeing with his identification of the bug.
Have you checked if this is perhaps a bug in scintilla and maybe fixed by https://github.com/geany/geany/pull/3551?
I just tried and no, it doesn't fix it unfortunately.
It's hard to say whether this is really a bug on the Scintilla side - I didn't investigate what exact Scintilla API gets called in Geany when filetypes change (one would have to go through the many calls in `highlighting.c` and see which one triggers it but it's not worth it). At the end it might just be some undefined behavior which worked in previous Scintilla versions but which doesn't work now.
It's hard to say whether this is really a bug on the Scintilla side
I guess this due to `SCI_SETILEXER`: each time it will set a new lexer for current document even if it has same identifier (`SCI_GETLEXER`) as previous one.
I've just added the 2.0 milestone here because this affects the ProjectOrganizer plugin and type colorization there.
LGBI
The diagnosis of @zufuliu above makes sense, a new lexer will always need new keywords to be set.
This may have been a bug for always, but not exposed until PO started swapping filetypes with abandon.
OK, merging.
Merged #3553 into master.
github-comments@lists.geany.org