Merge pull request #51333 from Razoric480/3x-sceneless-fix
[3.x] Fix LSP completion crashing on scene-less scripts
This commit is contained in:
commit
a0810f313f
|
@ -425,9 +425,13 @@ void GDScriptTextDocument::sync_script_content(const String &p_path, const Strin
|
||||||
GDScriptLanguageProtocol::get_singleton()->get_workspace()->parse_script(path, p_content);
|
GDScriptLanguageProtocol::get_singleton()->get_workspace()->parse_script(path, p_content);
|
||||||
|
|
||||||
EditorFileSystem::get_singleton()->update_file(path);
|
EditorFileSystem::get_singleton()->update_file(path);
|
||||||
Ref<GDScript> script = ResourceLoader::load(path);
|
Error error;
|
||||||
script->load_source_code(path);
|
Ref<GDScript> script = ResourceLoader::load(path, "", false, &error);
|
||||||
|
if (error == OK) {
|
||||||
|
if (script->load_source_code(path) == OK) {
|
||||||
script->reload(true);
|
script->reload(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GDScriptTextDocument::show_native_symbol_in_editor(const String &p_symbol_id) {
|
void GDScriptTextDocument::show_native_symbol_in_editor(const String &p_symbol_id) {
|
||||||
|
|
|
@ -517,8 +517,9 @@ 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);
|
|
||||||
|
|
||||||
|
if (owner_scene_node) {
|
||||||
|
stack.push_back(owner_scene_node);
|
||||||
while (!stack.empty()) {
|
while (!stack.empty()) {
|
||||||
current = stack.pop_back();
|
current = stack.pop_back();
|
||||||
Ref<GDScript> script = current->get_script();
|
Ref<GDScript> script = current->get_script();
|
||||||
|
@ -534,6 +535,7 @@ void GDScriptWorkspace::completion(const lsp::CompletionParams &p_params, List<S
|
||||||
if (!script.is_valid() || script->get_path() != path) {
|
if (!script.is_valid() || script->get_path() != path) {
|
||||||
current = owner_scene_node;
|
current = owner_scene_node;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String code = parser->get_text_for_completion(p_params.position);
|
String code = parser->get_text_for_completion(p_params.position);
|
||||||
GDScriptLanguage::get_singleton()->complete_code(code, path, current, r_options, forced, call_hint);
|
GDScriptLanguage::get_singleton()->complete_code(code, path, current, r_options, forced, call_hint);
|
||||||
|
|
Loading…
Reference in New Issue