1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:07:35 +00:00

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.
This commit is contained in:
Karol Kosek 2023-05-09 16:12:24 +02:00 committed by Sam Atkins
parent 259f4ffce1
commit 3c13faff57

View file

@ -136,6 +136,7 @@ ErrorOr<int> 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<int> 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<int> 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();