From 2c4aa50648c86f83dd11abc20cb2d4f34d49dbad Mon Sep 17 00:00:00 2001 From: Lightning_A Date: Thu, 22 Apr 2021 18:17:01 -0600 Subject: [PATCH] Fix Array.max() navigating to @GDScript.max() etc. --- modules/gdscript/gdscript_editor.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index 7bf7666434f..edcbe22a636 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -3342,15 +3342,6 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol } } - for (int i = 0; i < GDScriptFunctions::FUNC_MAX; i++) { - if (GDScriptFunctions::get_func_name(GDScriptFunctions::Function(i)) == p_symbol) { - r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_METHOD; - r_result.class_name = "@GDScript"; - r_result.class_member = p_symbol; - return OK; - } - } - if ("PI" == p_symbol || "TAU" == p_symbol || "INF" == p_symbol || "NAN" == p_symbol) { r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT; r_result.class_name = "@GDScript"; @@ -3566,6 +3557,16 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol } } + for (int i = 0; i < GDScriptFunctions::FUNC_MAX; i++) { + // this has to get run after parsing because otherwise functions like Array.max() will trigger it + if (GDScriptFunctions::get_func_name(GDScriptFunctions::Function(i)) == p_symbol) { + r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_METHOD; + r_result.class_name = "@GDScript"; + r_result.class_member = p_symbol; + return OK; + } + } + return ERR_CANT_RESOLVE; }