From 41744a4a870612028ef15a91dc8988355ad82d08 Mon Sep 17 00:00:00 2001 From: Marco Cutecchia Date: Tue, 13 Sep 2022 08:42:29 +0200 Subject: [PATCH] HackStudio: Prevent closing the last editor group Previously if the user closed the last open tab in the last TabWidget then the open file action would stop working until they explicitly went to the View menu and added a new editor group. Before this commit there was an attempt at preventing the user to close the last open tab by hiding its close button, this didn't account for the many other ways one could close it though. --- Userland/DevTools/HackStudio/HackStudioWidget.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index 4cf9ebdafb..f9f94358b2 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -794,15 +794,11 @@ void HackStudioWidget::add_new_editor(GUI::TabWidget& parent) set_current_editor_wrapper(tab); parent.remove_tab(tab); m_all_editor_wrappers.remove_first_matching([&tab](auto& entry) { return entry == &tab; }); - if (parent.children().is_empty()) { + if (parent.children().is_empty() && m_all_editor_tab_widgets.size() > 1) { m_switch_to_next_editor_tab_widget->activate(); m_editors_splitter->remove_child(parent); m_all_editor_tab_widgets.remove_first_matching([&parent](auto& entry) { return entry == &parent; }); - if (m_current_editor_tab_widget->children().size() == 1) - m_current_editor_tab_widget->set_close_button_enabled(false); } - if (parent.children().size() == 1 && m_all_editor_tab_widgets.size() <= 1) - parent.set_close_button_enabled(false); update_actions(); }); };