From 523dae6bbae303cba688846e8a7a67a02db38725 Mon Sep 17 00:00:00 2001 From: Yuri Roubinsky Date: Thu, 19 Mar 2020 21:26:35 +0300 Subject: [PATCH] Fix shader TIME auto-completion --- servers/visual/shader_language.cpp | 31 +++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp index 713b54e1bab..084ade88551 100644 --- a/servers/visual/shader_language.cpp +++ b/servers/visual/shader_language.cpp @@ -6722,18 +6722,27 @@ Error ShaderLanguage::complete(const String &p_code, const Mapparent_block; } - if (comp_ident && skip_function != StringName() && p_functions.has(skip_function)) { - - for (Map::Element *E = p_functions[skip_function].built_ins.front(); E; E = E->next()) { - ScriptCodeCompletionOption::Kind kind = ScriptCodeCompletionOption::KIND_MEMBER; - if (E->get().constant) { - kind = ScriptCodeCompletionOption::KIND_CONSTANT; - } - matches.insert(E->key(), kind); - } - } - if (comp_ident) { + if (p_functions.has("global")) { + for (Map::Element *E = p_functions["global"].built_ins.front(); E; E = E->next()) { + ScriptCodeCompletionOption::Kind kind = ScriptCodeCompletionOption::KIND_MEMBER; + if (E->get().constant) { + kind = ScriptCodeCompletionOption::KIND_CONSTANT; + } + matches.insert(E->key(), kind); + } + } + + if (skip_function != StringName() && p_functions.has(skip_function)) { + for (Map::Element *E = p_functions[skip_function].built_ins.front(); E; E = E->next()) { + ScriptCodeCompletionOption::Kind kind = ScriptCodeCompletionOption::KIND_MEMBER; + if (E->get().constant) { + kind = ScriptCodeCompletionOption::KIND_CONSTANT; + } + matches.insert(E->key(), kind); + } + } + for (const Map::Element *E = shader->varyings.front(); E; E = E->next()) { matches.insert(E->key(), ScriptCodeCompletionOption::KIND_VARIABLE); }