fix autosaving

This commit is contained in:
2025-11-16 21:08:50 -05:00
parent f462692bb1
commit d414375d82

View File

@@ -119,8 +119,16 @@ namespace anm2ed
{
if (!vector::in_bounds(documents, index)) return;
autosaveFiles.erase(std::remove(autosaveFiles.begin(), autosaveFiles.end(), get()->autosave_path_get()),
autosaveFiles.end());
const auto autosavePath = documents[index].autosave_path_get();
autosaveFiles.erase(std::remove(autosaveFiles.begin(), autosaveFiles.end(), autosavePath), autosaveFiles.end());
if (!autosavePath.empty())
{
std::error_code ec{};
std::filesystem::remove(autosavePath, ec);
if (ec) logger.warning(std::format("Could not remove autosave file {}: {}", autosavePath.string(), ec.message()));
}
autosave_files_write();
documents.erase(documents.begin() + index);