From 4a766245fa259beddbb45f2fd269c742668762ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filiph=20Sandstr=C3=B6m?= Date: Wed, 30 Nov 2022 12:20:04 +0100 Subject: [PATCH] HackStudio: Replace blank file when opening a new one Before this we just added a new tab and left the `(Untitled)` tab in the background. Now we instead check that it hasn't been modified and that it's empty; if both these conditions are true we replace the blank editor with the newly opened one. --- Userland/DevTools/HackStudio/HackStudioWidget.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index 17ab3a119d..8ab63ff730 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -318,6 +318,8 @@ bool HackStudioWidget::open_file(String const& full_filename, size_t line, size_ if (editor_wrapper_or_none.has_value()) { set_current_editor_wrapper(editor_wrapper_or_none.release_value()); return true; + } else if (active_file().is_empty() && !current_editor().document().is_modified() && !full_filename.is_empty()) { + // Replace "Untitled" blank file since it hasn't been modified } else { add_new_editor(*m_current_editor_tab_widget); }