From 070d63496622bfd87f98c8f49669b87756906834 Mon Sep 17 00:00:00 2001 From: Francois Belair Date: Fri, 6 Aug 2021 14:55:05 -0400 Subject: Fix LSP completion crashing on scene-less scripts --- modules/gdscript/language_server/gdscript_text_document.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'modules/gdscript/language_server/gdscript_text_document.cpp') diff --git a/modules/gdscript/language_server/gdscript_text_document.cpp b/modules/gdscript/language_server/gdscript_text_document.cpp index c0013ac23a..9574c765bc 100644 --- a/modules/gdscript/language_server/gdscript_text_document.cpp +++ b/modules/gdscript/language_server/gdscript_text_document.cpp @@ -431,9 +431,13 @@ void GDScriptTextDocument::sync_script_content(const String &p_path, const Strin GDScriptLanguageProtocol::get_singleton()->get_workspace()->parse_script(path, p_content); EditorFileSystem::get_singleton()->update_file(path); - Ref script = ResourceLoader::load(path); - script->load_source_code(path); - script->reload(true); + Error error; + Ref script = ResourceLoader::load(path, "", ResourceFormatLoader::CACHE_MODE_REUSE, &error); + if (error == OK) { + if (script->load_source_code(path) == OK) { + script->reload(true); + } + } } void GDScriptTextDocument::show_native_symbol_in_editor(const String &p_symbol_id) { -- cgit v1.2.3