Mark reimported projects as modified

Mark successfully reimported projects as modified so closing them prompts to save. Keep failed reimports atomic and add saved-project regression coverage.

Thanks @Agapenordev for the fix and regression test.
This commit is contained in:
Agapenor authored and GitHub committed 2026-11-05 17:30:59 +01:00
1 parent 6cceef19fd
commit 169221ea4c
1 file changed
+11
+11
View File
@@ -448,6 +448,7 @@ impl Session {
let mut next = Session::new(doc, mesh, source)?;
next.log.extend(warnings);
next.path = self.path.clone();
next.modified = true;
let preserved = preserve_strokes.then(|| crate::preserve::preserve_strokes(self, &mut next));
self.switch_to(next);
Ok(preserved.map_or(Value::Null, |n| json!({ "preserved": n })))
@@ -610,6 +611,16 @@ fn close(s: &mut Session, _: &Value) -> Result<Value> {
mod tests {
use super::*;
#[test]
fn reimporting_a_saved_project_marks_it_modified() {
let obj = b"v -1 -1 0\nv 1 -1 0\nv 1 1 0\nvt 0 0\nvt 1 0\nvt 1 1\nf 1/1 2/2 3/3\n";
let original = Session::from_mesh_bytes("mesh.obj", obj, 128, "mesh").unwrap();
let mut saved = Session::from_project_bytes(&original.to_project_bytes().unwrap()).unwrap();
assert!(!saved.modified);
crate::execute(&mut saved, "file.reimportMesh", &Value::Null).unwrap();
assert!(saved.modified, "reimport must trigger the unsaved-changes prompt");
}
#[test]
fn export_mesh_writes_obj_by_default_and_textured_glb() {
let mut s = Session::new_project("t", primitives::material_ball(), "builtin:material_ball", None, 128).unwrap();