From 4c11929fe2f9ccf3da118d6a345d37be610c5cb1 Mon Sep 17 00:00:00 2001 From: prxnvt <53838599+prxnvt@users.noreply.github.com> Date: Sat, 24 Oct 2026 23:44:24 -0400 Subject: [PATCH] Tests: a visible legacy name of the macro storage shape survives a save The stash reads a legacy _sc_ name as data whether or not it is hidden, so writing key macro_0 removed a person's visible _sc_macro_0 name with no word. The index allocator steps around that key as well; this test fails without it. --- crates/engine/src/macros/tests.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/crates/engine/src/macros/tests.rs b/crates/engine/src/macros/tests.rs index c3fd230c4..d87857177 100644 --- a/crates/engine/src/macros/tests.rs +++ b/crates/engine/src/macros/tests.rs @@ -260,6 +260,19 @@ fn a_huge_visible_index_takes_no_part_in_numbering() { assert_eq!(names_of(&back), names_of(&wb)); } +#[test] +fn a_visible_legacy_name_of_the_storage_shape_is_kept() { + // The stash reads a legacy `_sc_` name as data whether or not it is hidden, so writing + // key `macro_0` would remove a person's visible `_sc_macro_0`. That key is stepped around too. + let mut wb = Workbook::new(); + wb.macros.push(sample_macro("A")); + wb.names.push(visible("_sc_macro_0")); + let (raw, back) = xlsx_round_trip(&wb); + assert_eq!(raw, ["_sc_macro_0", "_gc_macro_1_0"]); + assert_eq!(back.macros, wb.macros); + assert_eq!(back.names, vec![visible("_sc_macro_0")]); +} + #[test] fn a_name_defined_after_opening_does_not_block_the_next_save() { // Once a file is open its macros are out of the names, so Define Name accepts a visible