mirror of
https://github.com/RGBCube/serenity
synced 2025-07-10 06:07:35 +00:00
HackStudio: Open by default the last opened project if not specified
This commit is contained in:
parent
7e7bfdac50
commit
cb041d7496
1 changed files with 20 additions and 3 deletions
|
@ -32,6 +32,7 @@ static WeakPtr<HackStudioWidget> s_hack_studio_widget;
|
||||||
static bool make_is_available();
|
static bool make_is_available();
|
||||||
static void notify_make_not_available();
|
static void notify_make_not_available();
|
||||||
static void update_path_environment_variable();
|
static void update_path_environment_variable();
|
||||||
|
static Optional<String> last_opened_project_path();
|
||||||
|
|
||||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
{
|
{
|
||||||
|
@ -59,9 +60,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
|
|
||||||
auto argument_absolute_path = Core::File::real_path_for(path_argument);
|
auto argument_absolute_path = Core::File::real_path_for(path_argument);
|
||||||
|
|
||||||
auto project_path = argument_absolute_path;
|
auto project_path = Core::File::real_path_for(".");
|
||||||
if (argument_absolute_path.is_null() || mode_coredump)
|
if (!mode_coredump) {
|
||||||
project_path = Core::File::real_path_for(".");
|
if (!argument_absolute_path.is_null())
|
||||||
|
project_path = argument_absolute_path;
|
||||||
|
else if (auto path = last_opened_project_path(); path.has_value())
|
||||||
|
project_path = path.release_value();
|
||||||
|
}
|
||||||
|
|
||||||
auto hack_studio_widget = TRY(window->try_set_main_widget<HackStudioWidget>(project_path));
|
auto hack_studio_widget = TRY(window->try_set_main_widget<HackStudioWidget>(project_path));
|
||||||
s_hack_studio_widget = hack_studio_widget;
|
s_hack_studio_widget = hack_studio_widget;
|
||||||
|
@ -123,6 +128,18 @@ static void update_path_environment_variable()
|
||||||
setenv("PATH", path.to_string().characters(), true);
|
setenv("PATH", path.to_string().characters(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Optional<String> last_opened_project_path()
|
||||||
|
{
|
||||||
|
auto projects = HackStudioWidget::read_recent_projects();
|
||||||
|
if (projects.size() == 0)
|
||||||
|
return {};
|
||||||
|
|
||||||
|
if (!Core::File::exists(projects[0]))
|
||||||
|
return {};
|
||||||
|
|
||||||
|
return { projects[0] };
|
||||||
|
}
|
||||||
|
|
||||||
namespace HackStudio {
|
namespace HackStudio {
|
||||||
|
|
||||||
GUI::TextEditor& current_editor()
|
GUI::TextEditor& current_editor()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue