From 0fbec848bb563692445bfadf3317701718527bf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Techet?= Date: Sun, 10 Sep 2023 23:51:54 +0200 Subject: [PATCH] Fix keyword colorization on filetype change 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. --- src/document.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/document.c b/src/document.c index 85c4e20e70..4cf74105b1 100644 --- a/src/document.c +++ b/src/document.c @@ -2824,6 +2824,9 @@ static void document_load_config(GeanyDocument *doc, GeanyFiletype *type, editor_set_indentation_guides(doc->editor); build_menu_update(doc); queue_colourise(doc); + /* forces re-setting SCI_SETKEYWORDS which seems to be needed with + * Scintilla 5 to colorize them properly */ + doc->priv->keyword_hash = 0; if (type->priv->symbol_list_sort_mode == SYMBOLS_SORT_USE_PREVIOUS) doc->priv->symbol_list_sort_mode = interface_prefs.symbols_sort_mode; else