From 412e87349a6f1c4f8989459d7a8c7f3a028833a4 Mon Sep 17 00:00:00 2001 From: Rindbee Date: Sun, 25 Sep 2022 23:13:39 +0800 Subject: [PATCH] Fix out of sync when the script is edited externally via lsp Previously, external editing via lsp would modify the modified time of the script, which caused the internal display of the script to not be refreshed when refocusing the engine. Now saving the script externally via lsp will automatically refresh the internal display. --- editor/plugins/script_editor_plugin.cpp | 47 ++++++++++--------- editor/plugins/script_editor_plugin.h | 2 +- .../gdscript_text_document.cpp | 1 + 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 8791da82456..e84248b3c01 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -2544,7 +2544,7 @@ void ScriptEditor::apply_scripts() const { } } -void ScriptEditor::reload_scripts() { +void ScriptEditor::reload_scripts(bool p_refresh_only) { for (int i = 0; i < tab_container->get_tab_count(); i++) { ScriptEditorBase *se = Object::cast_to(tab_container->get_tab_control(i)); if (!se) { @@ -2557,30 +2557,33 @@ void ScriptEditor::reload_scripts() { continue; //internal script, who cares } - uint64_t last_date = edited_res->get_last_modified_time(); - uint64_t date = FileAccess::get_modified_time(edited_res->get_path()); + if (!p_refresh_only) { + uint64_t last_date = edited_res->get_last_modified_time(); + uint64_t date = FileAccess::get_modified_time(edited_res->get_path()); - if (last_date == date) { - continue; + if (last_date == date) { + continue; + } + + Ref