From 461395d0a058f512a10e7293248b13b9ca0437e4 Mon Sep 17 00:00:00 2001 From: prxnvt <53838599+prxnvt@users.noreply.github.com> Date: Fri, 23 Oct 2026 23:09:02 -0400 Subject: [PATCH] Engine: col and cols keep the header state, so a later data takes the header off MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Input.col("date").data resolved to the whole column, header included, because every method cleared the header state. col and cols keep it; the other methods still clear it, and only data keeps the header row for col("…"). The token test asks for D3:D11, cols(2..3).data and col(2).data.col(1). --- crates/engine/src/macros/resolve.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/engine/src/macros/resolve.rs b/crates/engine/src/macros/resolve.rs index 03b9988da..4e84c0965 100644 --- a/crates/engine/src/macros/resolve.rs +++ b/crates/engine/src/macros/resolve.rs @@ -288,9 +288,12 @@ pub fn resolve_token(text: &str, env: &Env) -> R { return bad(format!("'{t}': '{name}' with these arguments isn't a token method ({}).", METHODS.join(", "))); } }; - // After a method the result is plain cells: `data` no longer applies, and only `data` - // keeps the header row for `col("…")`. - header = false; + // After a method the result is plain cells, except that `col` and `cols` keep the input's top + // row, so a later `data` still takes the header off; only `data` keeps the header row for + // `col("…")`. + if !matches!(method.as_str(), "col" | "cols") { + header = false; + } if method != "data" { names_row = None; } @@ -615,7 +618,9 @@ mod tests { ("input", "B2:D11"), ("Input.col(2)", "C2:C11"), ("Input.col(\"Amount\")", "C2:C11"), - ("Input.col(\"date\").data", "D2:D11"), + ("Input.col(\"date\").data", "D3:D11"), + ("Input.cols(2..3).data", "C3:D11"), + ("Input.col(2).data.col(1)", "C3:C11"), ("Input.data", "B3:D11"), ("Input.data.col(2)", "C3:C11"), ("Input.data.col(\"Amount\")", "C3:C11"),