Skip to content

Commit dade8bd

Browse files
committed
Update script modified times when saved in EditorNode
1 parent 134da37 commit dade8bd

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

editor/editor_node.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,6 +1867,7 @@ int EditorNode::_save_external_resources(bool p_also_save_external_data) {
18671867
res->set_edited(false);
18681868
}
18691869

1870+
bool script_was_saved = false;
18701871
for (const String &E : edited_resources) {
18711872
Ref<Resource> res = ResourceCache::get_ref(E);
18721873
if (res.is_null()) {
@@ -1876,10 +1877,18 @@ int EditorNode::_save_external_resources(bool p_also_save_external_data) {
18761877
if (ps.is_valid()) {
18771878
continue; // Do not save PackedScenes, this will mess up the editor.
18781879
}
1880+
if (!script_was_saved) {
1881+
Ref<Script> scr = res;
1882+
script_was_saved = scr.is_valid();
1883+
}
18791884
ResourceSaver::save(res, res->get_path(), flg);
18801885
saved++;
18811886
}
18821887

1888+
if (script_was_saved) {
1889+
ScriptEditor::get_singleton()->update_script_times();
1890+
}
1891+
18831892
if (p_also_save_external_data) {
18841893
for (int i = 0; i < editor_data.get_editor_plugin_count(); i++) {
18851894
EditorPlugin *plugin = editor_data.get_editor_plugin(i);

editor/plugins/script_editor_plugin.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2817,6 +2817,15 @@ void ScriptEditor::save_all_scripts() {
28172817
_update_script_names();
28182818
}
28192819

2820+
void ScriptEditor::update_script_times() {
2821+
for (int i = 0; i < tab_container->get_tab_count(); i++) {
2822+
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i));
2823+
if (se) {
2824+
se->edited_file_data.last_modified_time = FileAccess::get_modified_time(se->edited_file_data.path);
2825+
}
2826+
}
2827+
}
2828+
28202829
void ScriptEditor::apply_scripts() const {
28212830
for (int i = 0; i < tab_container->get_tab_count(); i++) {
28222831
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i));

editor/plugins/script_editor_plugin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,7 @@ class ScriptEditor : public PanelContainer {
569569
PackedStringArray get_unsaved_scripts() const;
570570
void save_current_script();
571571
void save_all_scripts();
572+
void update_script_times();
572573

573574
void set_window_layout(Ref<ConfigFile> p_layout);
574575
void get_window_layout(Ref<ConfigFile> p_layout);

0 commit comments

Comments
 (0)