fix: File provider sometimes not saving path to project file

This commit is contained in:
WerWolv
2023-01-19 11:09:24 +01:00
parent def40c908e
commit c5d2739a39
2 changed files with 10 additions and 5 deletions

View File

@@ -297,10 +297,13 @@ namespace hex::plugin::builtin {
}
nlohmann::json FileProvider::storeSettings(nlohmann::json settings) const {
std::string path;
if (auto projectPath = ProjectFile::getPath(); !projectPath.empty())
settings["path"] = hex::toUTF8String(std::fs::relative(this->m_path, projectPath.parent_path()));
else
settings["path"] = hex::toUTF8String(this->m_path);
path = hex::toUTF8String(std::fs::proximate(this->m_path, projectPath.parent_path()));
if (path.empty())
path = hex::toUTF8String(this->m_path);
settings["path"] = path;
return Provider::storeSettings(settings);
}