@@ -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
890891void 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
0 commit comments