Repository: godotengine/godot (language: cpp)

Issue:
Changing syntax highlight setting does not update text highlighting
### Tested versions

Reproducible in v4.4.dev6.official [1f47e4c4e]
Reproducible in v4.4.dev2.official [97ef3c837]
Not reproducible in v4.4.dev1.official [28a72fa43]
Not reproducible in Godot 4.3

### System information

Godot v4.4.dev2 - Windows 10.0.19045 - OpenGL 3 (Compatibility) - NVIDIA GeForce RTX 2060 (NVIDIA; 32.0.15.6590) - AMD Ryzen 7 4800H with Radeon Graphics (16 Threads)

### Issue description

A very minor regression. When a text or script file is open, changing the syntax highlighting setting under `Edit -> Syntax Highlighter -> [any setting]` does not cause the text to use the new syntax highlighting, until some change in the text is made or the file is closed and reopened.

May be considered a duplicate of #98367, though that one is related to changing editor theme, while this one is about changing a script editor setting. Feel free to close if tracking one issue is easier.

Possibly caused by #92865.

### Steps to reproduce

Create a text or script file and write something in it.
Open it in the built-in script editor.
Change Edit -> Syntax Highlighter to any option.
Notice no immediate change to syntax highlighting.
(if you edit the text, it will properly update)

### Minimal reproduction project (MRP)

This project includes two text files, one .txt and one .gd, with mostly identical contents. File type doesn't seem to matter, though.

[syntax_highlight_bug.zip](https://github.com/user-attachments/files/18140642/syntax_highlight_bug.zip)



Discussion / hints:

Fix patch:
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index a33769eaa994..1fbd2c48c0f0 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -2956,6 +2956,7 @@ void TextEdit::_update_caches() {
 	if (syntax_highlighter.is_valid()) {
 		syntax_highlighter->set_text_edit(this);
 	}
+	_clear_syntax_highlighting_cache();
 }
 
 void TextEdit::_close_ime_window() {
@@ -6428,6 +6429,7 @@ void TextEdit::set_syntax_highlighter(Ref<SyntaxHighlighter> p_syntax_highlighte
 	if (syntax_highlighter.is_valid()) {
 		syntax_highlighter->set_text_edit(this);
 	}
+	_clear_syntax_highlighting_cache();
 	queue_redraw();
 }
 


Test patch: