From 6742f6894e8d749f11275ab3858a4efc3d839354 Mon Sep 17 00:00:00 2001 From: lucasvanmol Date: Thu, 21 Jan 2021 11:46:32 +0000 Subject: [PATCH] Fix highlight color for class attributes that are also keywords Fixes #45338. This PR also makes any word after a "." not highlight as a keyword, i.e. the cos in Color.cos will highlight the same as any other class constant. Additionally, trying to do things like ".print()" will not highlight print as a keyword but as a class function. --- modules/gdscript/editor/gdscript_highlighter.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/gdscript/editor/gdscript_highlighter.cpp b/modules/gdscript/editor/gdscript_highlighter.cpp index 47db6e4ebe4..17e8a241b76 100644 --- a/modules/gdscript/editor/gdscript_highlighter.cpp +++ b/modules/gdscript/editor/gdscript_highlighter.cpp @@ -191,19 +191,21 @@ Map GDScriptSyntaxHighlighter::_get_line_syntax_ col = text_editor->get_keyword_color(word); } else if (text_editor->has_member_color(word)) { col = text_editor->get_member_color(word); + } + + if (col != Color()) { for (int k = j - 1; k >= 0; k--) { if (str[k] == '.') { - col = Color(); //member indexing not allowed + col = Color(); // keyword & member indexing not allowed break; } else if (str[k] > 32) { break; } } - } - - if (col != Color()) { - in_keyword = true; - keyword_color = col; + if (col != Color()) { + in_keyword = true; + keyword_color = col; + } } }