Review fixes for #3042: "" with parse: false keeps the cell's formatting; correct the write_range parse description

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Brandon Thomas
2026-11-01 12:20:54 -05:00
co-authored by Claude Opus 5.5
parent 653227fe6e
commit ea1d52fe8f
3 changed files with 7 additions and 3 deletions
+2 -2
View File
@@ -245,8 +245,8 @@ pub(super) fn range_set_values(s: &mut Session, p: &Json) -> Result<Json> {
if text.is_empty() {
// An empty string clears the cell, as `null` and the default path do:
// an empty text cell is not blank, and a script clearing cells with
// `""` would leave cells `COUNTA` counts.
None
// `""` would leave cells `COUNTA` counts. The cell keeps its formatting.
input_to_cell("", sheet, at, &mut cx.wb)?
} else {
let mut style = cx.wb.sheet(sheet).map(|sh| sh.style_id(at)).unwrap_or_default();
// Line breaks still turn on Wrap Text, as typed input does.
+4
View File
@@ -225,10 +225,14 @@ fn set_values_parse_false_clears_an_empty_string() {
let mut s = Session::new();
s.new_workbook();
s.execute("range.setValues", json!({"range": "A1:B1", "values": [["keep", "keep"]]})).unwrap();
s.execute("home.bold", json!({"range": "A1"})).unwrap();
s.execute("range.setValues", json!({"range": "A1", "parse": false, "values": [["", ""]]})).unwrap();
let get = |s: &mut Session, a: &str| s.execute("cell.get", json!({"cell": a})).unwrap();
assert_eq!(get(&mut s, "A1")["type"], "empty");
assert_eq!(get(&mut s, "B1")["type"], "empty");
let d = s.doc().unwrap();
let sh = d.wb.sheet(0).unwrap();
assert!(d.wb.styles.get(sh.style_id(CellRef::parse("A1").unwrap())).font.bold, "clearing with \"\" keeps the formatting");
assert_eq!(s.execute("formulas.evaluate", json!({"formula": "=COUNTA(A1:B1)"})).unwrap(), json!(0.0));
}
+1 -1
View File
@@ -196,7 +196,7 @@ fn base_tool_definitions() -> Vec<Value> {
json!({
"range": string("Top-left cell or range, e.g. \"A1\" or \"Sheet2!B3\""),
"values": {"type": "array", "description": "Rows of cell values", "items": {"type": "array", "items": {"type": ["string", "number", "boolean", "null"]}}},
"parse": boolean("Store every string not starting with = as the text it is, instead of reading it like typed input (default true)"),
"parse": boolean("Read strings not starting with = like typed input, so \"05.04.2026\" becomes a date (default true); false stores them as the text they are, and \"\" clears the cell"),
}),
&["range", "values"],
),