[studio/applib] Make Studio remove files unable to be opened from open file list in config

This commit is contained in:
2025-07-07 23:35:28 -05:00
parent f6ef2b5acb
commit f5f2c3bee6

View File

@ -673,14 +673,18 @@ ox::Error StudioUI::openProjectPath(ox::StringParam path) noexcept {
auto p = std::move(*pcIt); auto p = std::move(*pcIt);
std::ignore = config.projects.erase(pcIt); std::ignore = config.projects.erase(pcIt);
auto &pc = *config.projects.emplace(0, std::move(p)); auto &pc = *config.projects.emplace(0, std::move(p));
for (auto const &f: pc.openFiles) { std::ignore = pc.openFiles.erase(
std::remove_if(
pc.openFiles.begin(), pc.openFiles.end(),
[&](ox::String const &f) {
auto const openFileErr = openFileActiveTab(f, pc.activeTabItemName == f); auto const openFileErr = openFileActiveTab(f, pc.activeTabItemName == f);
if (openFileErr) { if (openFileErr) {
oxErrorf("\nCould not open editor for file:\n\t{}\nReason:\n\t{}\n", f, toStr(openFileErr)); oxErrorf("\nCould not open editor for file:\n\t{}\nReason:\n\t{}\n", f, toStr(openFileErr));
continue; return true;
} }
m_activeEditor = m_editors.back().value->get(); m_activeEditor = m_editors.back().value->get();
} return false;
}));
} else { } else {
config.projects.emplace(0, StudioConfig::ProjectConfig{ config.projects.emplace(0, StudioConfig::ProjectConfig{
.projectPath = ox::String{m_project->projectPath()}, .projectPath = ox::String{m_project->projectPath()},