fix(formula): fix formula update operation (#4026)

Co-authored-by: wpxp123456 <Wpxp1223456>
This commit is contained in:
wpxp123456
2024-11-12 14:14:07 +08:00
committed by GitHub
co-authored by wpxp123456
parent 9040e5f997
commit 54599ce86c
@@ -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[] = [];