From 1f0fa16a15e47b3c1cf5f0638d9236df099f2e2c Mon Sep 17 00:00:00 2001 From: Francois Belair Date: Thu, 5 Aug 2021 11:45:37 -0400 Subject: [PATCH] Fix LSP parsing get_node only from the scene root (cherry picked from commit 03f8fa9f62c97648491a0d8f0dd7fac6808eb9b4) --- .../language_server/gdscript_workspace.cpp | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/modules/gdscript/language_server/gdscript_workspace.cpp b/modules/gdscript/language_server/gdscript_workspace.cpp index 5f2d59597f5..2de15177a06 100644 --- a/modules/gdscript/language_server/gdscript_workspace.cpp +++ b/modules/gdscript/language_server/gdscript_workspace.cpp @@ -514,8 +514,29 @@ void GDScriptWorkspace::completion(const lsp::CompletionParams &p_params, List script = current->get_script(); + if (script.is_valid() && script->get_path() == path) { + break; + } + for (int i = 0; i < current->get_child_count(); ++i) { + stack.push_back(current->get_child(i)); + } + } + + Ref script = current->get_script(); + if (!script.is_valid() || script->get_path() != path) { + current = owner_scene_node; + } + String code = parser->get_text_for_completion(p_params.position); - GDScriptLanguage::get_singleton()->complete_code(code, path, owner_scene_node, r_options, forced, call_hint); + GDScriptLanguage::get_singleton()->complete_code(code, path, current, r_options, forced, call_hint); if (owner_scene_node) { memdelete(owner_scene_node); }