From 54599ce86c0f0f62247ca3aa78b5972a377fb06d Mon Sep 17 00:00:00 2001 From: wpxp123456 <2677556700@qq.com> Date: Tue, 12 Nov 2024 14:14:07 +0800 Subject: [PATCH] fix(formula): fix formula update operation (#4026) Co-authored-by: wpxp123456 --- .../src/controllers/utils/ref-range-formula.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/sheets-formula/src/controllers/utils/ref-range-formula.ts b/packages/sheets-formula/src/controllers/utils/ref-range-formula.ts index 2ba47f2c1f..2cf46619c5 100644 --- a/packages/sheets-formula/src/controllers/utils/ref-range-formula.ts +++ b/packages/sheets-formula/src/controllers/utils/ref-range-formula.ts @@ -16,7 +16,7 @@ import type { ICellData, IMutationInfo, IObjectMatrixPrimitiveType, IRange, Nullable } from '@univerjs/core'; import type { ISetRangeValuesMutationParams } from '@univerjs/sheets'; -import { cellToRange, Direction, isFormulaId, isFormulaString, ObjectMatrix, Rectangle } from '@univerjs/core'; +import { cellToRange, Direction, isFormulaId, isFormulaString, ObjectMatrix, Rectangle, Tools } from '@univerjs/core'; import { deserializeRangeWithSheetWithCache, type IFormulaData, type IFormulaDataItem, type IRangeChange, type ISequenceNode, sequenceNodeType, serializeRangeToRefString } from '@univerjs/engine-formula'; import { EffectRefRangId, handleDeleteRangeMoveLeft, handleDeleteRangeMoveUp, handleInsertCol, handleInsertRangeMoveDown, handleInsertRangeMoveRight, handleInsertRow, handleIRemoveCol, handleIRemoveRow, handleMoveCols, handleMoveRange, handleMoveRows, runRefRangeMutations, SetRangeValuesMutation } from '@univerjs/sheets'; import { checkFormulaDataNull } from './offset-formula-data'; @@ -151,6 +151,14 @@ export function getFormulaReferenceRange(oldFormulaData: IFormulaData, const { sheetId: subUnitId, unitId } = formulaReferenceMoveParam; const { redoFormulaData, undoFormulaData } = refRangeFormula(oldFormulaData, newFormulaData, formulaReferenceMoveParam); + // If the formula data is the same, no operation is required + if (Tools.diffValue(redoFormulaData, undoFormulaData)) { + return { + undos: [], + redos: [], + }; + } + const redos: IMutationInfo[] = []; const undos: IMutationInfo[] = [];