From f5f2c3bee672b5ae496f1dddc8dd4d079fb6d5b0 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Mon, 7 Jul 2025 23:35:28 -0500 Subject: [PATCH] [studio/applib] Make Studio remove files unable to be opened from open file list in config --- src/olympic/studio/applib/src/studioui.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/olympic/studio/applib/src/studioui.cpp b/src/olympic/studio/applib/src/studioui.cpp index 441c0f4d..04c97e88 100644 --- a/src/olympic/studio/applib/src/studioui.cpp +++ b/src/olympic/studio/applib/src/studioui.cpp @@ -673,14 +673,18 @@ ox::Error StudioUI::openProjectPath(ox::StringParam path) noexcept { auto p = std::move(*pcIt); std::ignore = config.projects.erase(pcIt); auto &pc = *config.projects.emplace(0, std::move(p)); - for (auto const &f: pc.openFiles) { - auto const openFileErr = openFileActiveTab(f, pc.activeTabItemName == f); - if (openFileErr) { - oxErrorf("\nCould not open editor for file:\n\t{}\nReason:\n\t{}\n", f, toStr(openFileErr)); - continue; - } - m_activeEditor = m_editors.back().value->get(); - } + 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); + if (openFileErr) { + oxErrorf("\nCould not open editor for file:\n\t{}\nReason:\n\t{}\n", f, toStr(openFileErr)); + return true; + } + m_activeEditor = m_editors.back().value->get(); + return false; + })); } else { config.projects.emplace(0, StudioConfig::ProjectConfig{ .projectPath = ox::String{m_project->projectPath()},