From de84b3fa1c9bcba80a675e837414eb0f96b24aef Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 22 Jun 2021 19:19:47 +0200 Subject: [PATCH] Playground: Ask to save changes even when the document was never saved This makes sure to ask the user whether they want to save changes to their current document when opening a file even if the document has never been saved before. --- Userland/DevTools/Playground/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/DevTools/Playground/main.cpp b/Userland/DevTools/Playground/main.cpp index b65d65b9a4..0fc5ecb5a0 100644 --- a/Userland/DevTools/Playground/main.cpp +++ b/Userland/DevTools/Playground/main.cpp @@ -172,11 +172,11 @@ int main(int argc, char** argv) }); file_menu.add_action(GUI::CommonActions::make_open_action([&](auto&) { - if (!file_path.is_empty() && window->is_modified()) { + if (window->is_modified()) { auto save_document_first_result = GUI::MessageBox::show(window, "Save changes to current document first?", "Warning", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNoCancel); if (save_document_first_result == GUI::Dialog::ExecResult::ExecYes) save_action->activate(); - if (save_document_first_result == GUI::Dialog::ExecResult::ExecCancel) + if (save_document_first_result != GUI::Dialog::ExecResult::ExecNo && window->is_modified()) return; }