Fix LSP completion crashing on sceneless scripts
(cherry picked from commit 6db17a523e
)
This commit is contained in:
parent
a384ffa2b0
commit
9d0e0fe783
@ -445,22 +445,24 @@ void GDScriptWorkspace::completion(const lsp::CompletionParams &p_params, List<S
|
|||||||
|
|
||||||
Array stack;
|
Array stack;
|
||||||
Node *current = nullptr;
|
Node *current = nullptr;
|
||||||
stack.push_back(owner_scene_node);
|
|
||||||
|
|
||||||
while (!stack.empty()) {
|
if (owner_scene_node) {
|
||||||
current = stack.pop_back();
|
stack.push_back(owner_scene_node);
|
||||||
|
while (!stack.empty()) {
|
||||||
|
current = stack.pop_back();
|
||||||
|
Ref<GDScript> 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<GDScript> script = current->get_script();
|
Ref<GDScript> script = current->get_script();
|
||||||
if (script.is_valid() && script->get_path() == path) {
|
if (!script.is_valid() || script->get_path() != path) {
|
||||||
break;
|
current = owner_scene_node;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < current->get_child_count(); ++i) {
|
|
||||||
stack.push_back(current->get_child(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ref<GDScript> 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);
|
String code = parser->get_text_for_completion(p_params.position);
|
||||||
|
Loading…
Reference in New Issue
Block a user