Skip to content

Commit a4fbe4c

Browse files
committed
Merge pull request godotengine#91081 from KoBeWi/closing_faster_than_light
Further speed up closing multiple scripts
2 parents ba3007d + fd3ed99 commit a4fbe4c

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

editor/plugins/script_editor_plugin.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -863,28 +863,29 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) {
863863
_save_editor_state(current);
864864
}
865865
memdelete(tselected);
866-
if (idx >= tab_container->get_tab_count()) {
867-
idx = tab_container->get_tab_count() - 1;
868-
}
869-
if (idx >= 0) {
870-
if (history_pos >= 0) {
871-
idx = tab_container->get_tab_idx_from_control(history[history_pos].control);
872-
}
873-
_go_to_tab(idx);
874-
} else {
875-
_update_selected_editor_menu();
876-
}
877866

878867
if (script_close_queue.is_empty()) {
868+
if (idx >= tab_container->get_tab_count()) {
869+
idx = tab_container->get_tab_count() - 1;
870+
}
871+
if (idx >= 0) {
872+
if (history_pos >= 0) {
873+
idx = tab_container->get_tab_idx_from_control(history[history_pos].control);
874+
}
875+
_go_to_tab(idx);
876+
} else {
877+
_update_selected_editor_menu();
878+
}
879+
879880
_update_history_arrows();
880881
_update_script_names();
881882
_save_layout();
882883
_update_find_replace_bar();
883884
}
884885
}
885886

886-
void ScriptEditor::_close_current_tab(bool p_save) {
887-
_close_tab(tab_container->get_current_tab(), p_save);
887+
void ScriptEditor::_close_current_tab(bool p_save, bool p_history_back) {
888+
_close_tab(tab_container->get_current_tab(), p_save, p_history_back);
888889
}
889890

890891
void ScriptEditor::_close_discard_current_tab(const String &p_str) {
@@ -948,7 +949,7 @@ void ScriptEditor::_queue_close_tabs() {
948949
}
949950
}
950951

951-
_close_current_tab(false);
952+
_close_current_tab(false, false);
952953
}
953954
_update_find_replace_bar();
954955
}
@@ -4153,7 +4154,7 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) {
41534154
erase_tab_confirm = memnew(ConfirmationDialog);
41544155
erase_tab_confirm->set_ok_button_text(TTR("Save"));
41554156
erase_tab_confirm->add_button(TTR("Discard"), DisplayServer::get_singleton()->get_swap_cancel_ok(), "discard");
4156-
erase_tab_confirm->connect("confirmed", callable_mp(this, &ScriptEditor::_close_current_tab).bind(true));
4157+
erase_tab_confirm->connect("confirmed", callable_mp(this, &ScriptEditor::_close_current_tab).bind(true, true));
41574158
erase_tab_confirm->connect("custom_action", callable_mp(this, &ScriptEditor::_close_discard_current_tab));
41584159
add_child(erase_tab_confirm);
41594160

editor/plugins/script_editor_plugin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ class ScriptEditor : public PanelContainer {
374374
void _close_tab(int p_idx, bool p_save = true, bool p_history_back = true);
375375
void _update_find_replace_bar();
376376

377-
void _close_current_tab(bool p_save = true);
377+
void _close_current_tab(bool p_save = true, bool p_history_back = true);
378378
void _close_discard_current_tab(const String &p_str);
379379
void _close_docs_tab();
380380
void _close_other_tabs();

0 commit comments

Comments
 (0)