From 83ae63f79352bd0e473af0b4049b0dffdb2b0f2a Mon Sep 17 00:00:00 2001 From: prxnvt <53838599+prxnvt@users.noreply.github.com> Date: Wed, 21 Oct 2026 15:18:15 -0400 Subject: [PATCH] Engine: a stash item with only later chunks reads as missing and falls back to the legacy name With chunk _gc_k_2 but no _gc_k_0, get returned Some("") and never looked at _sc_k. It now takes the legacy path unless chunk 0 exists. --- crates/engine/src/cmd/stash.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/stash.rs b/crates/engine/src/cmd/stash.rs index a31d58752..fd8612ad0 100644 --- a/crates/engine/src/cmd/stash.rs +++ b/crates/engine/src/cmd/stash.rs @@ -40,7 +40,7 @@ pub fn get(wb: &Workbook, key: &str) -> Option { } } let mut out = String::new(); - if chunks.is_empty() { + if !chunks.contains_key(&0) { out = string_literals(legacy?); } else { // Chunks run 0, 1, 2, …; anything after a gap isn't part of the item. @@ -269,6 +269,11 @@ mod tests { wb.names.push(name("_gc_gap_0", "\"a\"")); wb.names.push(name("_gc_gap_2", "\"c\"")); assert_eq!(get(&wb, "gap").as_deref(), Some("a")); + // Only a later chunk: no item, and the legacy name is still read. + wb.names.push(name("_gc_orphan_2", "\"c\"")); + assert_eq!(get(&wb, "orphan"), None); + wb.names.push(name("_sc_orphan", "\"old\"")); + assert_eq!(get(&wb, "orphan").as_deref(), Some("old")); // Chunks out of order, a duplicate, junk around the literals, an unterminated literal. wb.names.push(name("_gc_mix_1", "\"b\"&A1&")); wb.names.push(name("_gc_mix_0", "SUM(\"a\")"));