Files
pdfcraft/crates/engine/src
Valentin Klein 996d34f432 A hidden layer stays hidden after a full Save As
A layer I hid stays hidden in the open document after a full Save As.

Fixes #7411

<details><summary>Details for review</summary>

**Cause:** the issue's analysis is right. A full save rewrites the file and renumbers its objects, then `mark_saved` refreshes the open document. The refresh looked old layer choices up by the old object number, and the renderer's layer overrides (`config.layers`) still named the old numbers, so the hidden layer came back as shown. An incremental save keeps the numbers, which is why it was unaffected.

**Fix:** `mark_saved` now knows when the saved bytes are a rewrite (it already computed that to reset the script runtime). In that case the refresh carries the visibility over by layer name (the nth layer with a name maps to the nth layer with that name, the writer keeps the `/OCGs` order) and rebuilds the renderer's overrides with the new numbers. Name matching also avoids an old number being reused by a different layer. The undo history survives the save, so undo and redo bring back a graph with the old numbers; when the restored layer numbers differ from the open document's, they use the same carry-over by name. Other refreshes are unchanged.

**Test** (`crates/engine/src/tests.rs`): `a_full_save_as_keeps_the_layer_choices_of_the_open_document` hides one of two layers whose objects get renumbered by the rewrite, saves in full, and checks both the layer list and the rendered pixels. Without the fix it fails with the hidden layer shown again (I checked this). `undo_and_redo_after_a_full_save_as_keep_the_hidden_layer_hidden` hides a layer after an edit, saves in full, then undoes and redoes, checking the layer list and the pixels each time (it fails without the undo/redo carry-over).

Checked: `cargo test -p pdfcraft-engine` (779 unit tests pass in the lib, the other test binaries pass; 7 OCR tests fail here because of the OCR setup on my machine, unrelated to layers), clippy `-D warnings --all-targets`, rustfmt, `xtask layers`. I did not run the native app.

</details>
2026-11-18 16:38:39 +07:00
..
…
…
2026-11-16 08:59:35 +01:00
…
2026-11-12 20:53:37 +01:00
…