From 3c13faff57c547dfde97e1f37a0e368ed39b8385 Mon Sep 17 00:00:00 2001 From: Karol Kosek Date: Tue, 9 May 2023 16:12:24 +0200 Subject: [PATCH] GMLPlayground: Set file path when reading file We weren't setting the path on the 'Open' action, which meant that a startup file name was always visible in the title bar (unless we save a file to a different path, or pick a file from the 'recent files' list). By setting it to update the stored file path in the load_file() function, it'll be guaranteed the file name will always be set. This also will add the startup opened file to the recently opened files list. --- Userland/DevTools/GMLPlayground/main.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Userland/DevTools/GMLPlayground/main.cpp b/Userland/DevTools/GMLPlayground/main.cpp index dbb92bee37..93a71d9f0e 100644 --- a/Userland/DevTools/GMLPlayground/main.cpp +++ b/Userland/DevTools/GMLPlayground/main.cpp @@ -136,6 +136,7 @@ ErrorOr serenity_main(Main::Arguments arguments) editor->set_text(buffer_or_error.release_value()); editor->set_focus(true); + file_path = file.filename().to_deprecated_string(); update_title(); GUI::Application::the()->set_most_recently_open_file(file.filename()); @@ -209,7 +210,6 @@ ErrorOr serenity_main(Main::Arguments arguments) auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(window, action.text()); if (response.is_error()) return; - file_path = response.value().filename().to_deprecated_string(); load_file(response.release_value()); })); @@ -337,9 +337,7 @@ ErrorOr serenity_main(Main::Arguments arguments) update_title(); } else { auto file = TRY(FileSystemAccessClient::Client::the().request_file_read_only_approved(window, path)); - file_path = path; - editor->set_text(TRY(file.release_stream()->read_until_eof())); - update_title(); + load_file(move(file)); } return app->exec();