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

HackStudio: Absolutize project paths before opening them

Relative paths cause issues in a couple of ways:
- `open_project()` sets the working directory to that path, and then
  opens a project at that same path. This means opening `./foo` goes to
  `./foo`, and then tries to open `./foo/foo`.
- Even with that rearranged, we would then have issues with trying to
  open files, because again we would try to open `./foo/foo/file`
  instead of `./foo/file`.
- The relative path would get saved in "Recent Projects" which is wrong.

Absolutizing the path before using it means we avoid these issues, and
without having to rearchitect everything. :^)
This commit is contained in:
Sam Atkins 2024-01-15 17:50:48 +00:00 committed by Andreas Kling
parent 6db4d3b898
commit dd9f3c980f
2 changed files with 7 additions and 5 deletions

View file

@ -18,6 +18,7 @@ Project::Project(ByteString const& root_path)
OwnPtr<Project> Project::open_with_root_path(ByteString const& root_path)
{
VERIFY(LexicalPath(root_path).is_absolute());
if (!FileSystem::is_directory(root_path))
return {};
return adopt_own(*new Project(root_path));