Integration: #2588 keep XMP-only document information across full refreshes

Session::refresh_with_indexes fills title, author and the other fields from XMP as build_document does; the test applies an edit and an undo and checks they stay.
This commit is contained in:
aiongg
2026-10-24 07:10:11 +00:00
parent b232ed217c
commit deffc376cf
2 changed files with 15 additions and 0 deletions
+7
View File
@@ -4413,6 +4413,13 @@ impl Session {
}
}
note_warnings(&mut info.warnings, &doc.xfa_warnings);
// As in `build_document`: the inspection reads only `/Info`, so fields stated only in XMP
// are filled in again after every full refresh.
for (field, value) in info_fields(&mut info, &editor.cos) {
if field.is_none() {
*field = value;
}
}
doc.info = info;
doc.fonts_stale = false;
let mut form = pdfcraft_forms::fields(&editor.cos);
+8
View File
@@ -555,6 +555,14 @@ fn document_information_stated_only_in_xmp_is_shown() {
assert_eq!((doc.info.title.as_deref(), doc.info.author.as_deref(), doc.info.subject.as_deref()), (Some("Quarterly report"), Some("Ada"), None));
assert_eq!(doc.info_value("Title").as_deref(), Some("Quarterly report"));
assert_eq!(doc.info_value("Author").as_deref(), Some("Ada"));
// A full refresh (any structural edit, undo, redo) reads /Info again and must not lose them.
s.apply(id, Edit::RotatePages { pages: vec![0], degrees: 90 }).unwrap();
let doc = s.get(id).unwrap();
assert_eq!((doc.info.title.as_deref(), doc.info.author.as_deref()), (Some("Quarterly report"), Some("Ada")), "after an edit");
s.undo(id).unwrap();
let doc = s.get(id).unwrap();
assert_eq!((doc.info.title.as_deref(), doc.info.author.as_deref()), (Some("Quarterly report"), Some("Ada")), "after undo");
}
#[test]