From 4857943a71235465dc06968b632faa1074256a3d Mon Sep 17 00:00:00 2001 From: Nicholas Hollett Date: Mon, 26 Jul 2021 21:20:07 +0100 Subject: [PATCH] HackStudio: Resize editors when removing panes Splitter does weird things when you resize and then remove children. This works around the limitation by forcing at least one of the editors to fill the space. It's janky, but at least doesn't result in the last editor not filling the window. --- Userland/DevTools/HackStudio/HackStudioWidget.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index 16603c6b00..79b2ba469c 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -553,6 +553,18 @@ NonnullRefPtr HackStudioWidget::create_remove_current_editor_action auto wrapper = m_current_editor_wrapper; m_switch_to_next_editor->activate(); m_editors_splitter->remove_child(*wrapper); + + auto child_editors = m_editors_splitter->child_widgets(); + bool has_child_to_fill_space = false; + for (auto& editor : child_editors) { + if (editor.max_height() == -1) { + has_child_to_fill_space = true; + break; + } + } + if (!has_child_to_fill_space) + child_editors.last().set_max_height(-1); + m_all_editor_wrappers.remove_first_matching([&wrapper](auto& entry) { return entry == wrapper.ptr(); }); update_actions(); });