Skip to content

cmd: quoted sheet targets, '=' separator, and 2D lists for set - #2

Merged
Jerome Leclanche (jleclanche) merged 1 commit into
mainfrom
fix/set-parser
Aug 26, 2026
Merged

cmd: quoted sheet targets, '=' separator, and 2D lists for set#2
Jerome Leclanche (jleclanche) merged 1 commit into
mainfrom
fix/set-parser

Conversation

@jleclanche

Copy link
Copy Markdown
Member

Three parser fixes surfaced by a real agent session (five `sheet_exec` calls for one edit):

  • Quoted sheet names never parsed as targets. `split_word` split on the first whitespace with no quote awareness, so `set 'Inv 343696 legs'!A1 …` failed with `cannot parse target "'Inv"` even though `help` lists `'My Sheet'!A1`. It is now quote-aware.
  • The `=` separator leaked into scalar values. Only the list form stripped it; `set A1 = "x"` handed `= "x"` to the engine as a formula (worked by luck), `set A1 = =SUM(..)` produced `#ERROR!`, and `set A1 = 2025-10-26` would silently store a formula evaluating to 1989. A `=` followed by whitespace is now the separator; formulas are `=SUM(` with no space.
  • `set = [[row], [row]]`. Writing a 20-row table took 20 `set A3:F3 = […]` lines. Nested lists write it in one command; `split_list` now respects bracket depth. Shape mismatches are errors.

Tests added for all three; `help` updated.

🤖 Generated with Claude Code

- split_word is quote-aware, so 'My Sheet'!A1 (which help already
  advertised) parses instead of failing on "'My".
- A '=' followed by whitespace after the target is the separator, not the
  value: set A1 = =SUM(..) is a formula, set A1 = 2025-10-26 a literal.
  Before, the scalar path passed '= …' to the engine as a formula.
- set <range> = [[row], [row]] writes a table in one command.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 26, 2026 16:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the sheet_exec command parser to better match documented set syntax and reduce ambiguity around sheet targets, separators, and list parsing.

Changes:

  • Make target parsing quote-aware so 'My Sheet'!A1 is treated as a single target token.
  • Treat = (equals + whitespace) as an optional separator for set, avoiding accidental formula interpretation of scalar literals.
  • Add support for 2D list inputs ([[row...], [row...]]) when setting multi-row ranges, and enhance list splitting to respect bracket depth.
Suppressed comments (1)

crates/sheetkit/src/cmd.rs:418

  • cmd_set validates raw.is_empty() before stripping the optional = separator, and the usage string doesn’t mention the newly-supported 2D list form. If the user provides only a separator (e.g. set A1 =), this path can fall through and produce a less helpful engine error rather than the set usage error.
    let raw = strip_separator(raw);
    if raw.starts_with('[') {
        let inner = raw

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +214 to 220
fn strip_separator(raw: &str) -> &str {
let trimmed = raw.trim();
match trimmed.strip_prefix('=') {
Some(rest) if rest.starts_with(char::is_whitespace) => rest.trim_start(),
_ => trimmed,
}
}
@jleclanche
Jerome Leclanche (jleclanche) merged commit 3435fe3 into main Aug 26, 2026
4 checks passed
@jleclanche
Jerome Leclanche (jleclanche) deleted the fix/set-parser branch August 26, 2026 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants