From 556af14ffb6e604089bb995a242d52de4976903a Mon Sep 17 00:00:00 2001 From: David Figatner Date: Thu, 19 Dec 2024 11:51:14 -0800 Subject: [PATCH] change old format operation --- quadratic-core/src/values/from_js.rs | 38 +++++++++++++++++----------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/quadratic-core/src/values/from_js.rs b/quadratic-core/src/values/from_js.rs index 8ac2f5fe7a..3e927042fa 100644 --- a/quadratic-core/src/values/from_js.rs +++ b/quadratic-core/src/values/from_js.rs @@ -6,8 +6,11 @@ use chrono::{NaiveDate, NaiveDateTime, NaiveTime}; use crate::{ controller::operations::operation::Operation, - grid::{formatting::CellFmtArray, NumericFormat, NumericFormatKind, Sheet}, - Pos, RunLengthEncoding, + grid::{ + formats::{FormatUpdate, SheetFormatUpdates}, + NumericFormat, NumericFormatKind, Sheet, + }, + A1Selection, Pos, }; use super::CellValue; @@ -48,7 +51,6 @@ impl CellValue { sheet: &mut Sheet, ) -> Result<(CellValue, Vec)> { let mut ops = vec![]; - let sheet_rect = crate::SheetRect::single_pos(pos, sheet.id); let cell_value = match js_type { "text" => { @@ -73,12 +75,15 @@ impl CellValue { .numeric_format .set(pos, Some(numeric_format.clone())); - ops.push(Operation::SetCellFormats { - sheet_rect, - attr: CellFmtArray::NumericFormat(RunLengthEncoding::repeat( - Some(numeric_format), - 1, - )), + ops.push(Operation::SetCellFormatsA1 { + sheet_id: sheet.id, + formats: SheetFormatUpdates::from_selection( + &A1Selection::from_single_cell(pos.to_sheet_pos(sheet.id)), + FormatUpdate { + numeric_format: Some(Some(numeric_format.clone())), + ..Default::default() + }, + ), }); // We no longer automatically set numeric decimals for @@ -97,12 +102,15 @@ impl CellValue { .formats .numeric_format .set(pos, Some(numeric_format.clone())); - ops.push(Operation::SetCellFormats { - sheet_rect, - attr: CellFmtArray::NumericFormat(RunLengthEncoding::repeat( - Some(numeric_format), - 1, - )), + ops.push(Operation::SetCellFormatsA1 { + sheet_id: sheet.id, + formats: SheetFormatUpdates::from_selection( + &A1Selection::from_single_cell(pos.to_sheet_pos(sheet.id)), + FormatUpdate { + numeric_format: Some(Some(numeric_format.clone())), + ..Default::default() + }, + ), }); CellValue::Number(number)