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.