diff --git a/packages/core/src/modules/formula.ts b/packages/core/src/modules/formula.ts index 9df33c9c..6a6f6b9d 100644 --- a/packages/core/src/modules/formula.ts +++ b/packages/core/src/modules/formula.ts @@ -947,7 +947,8 @@ export function insertUpdateFunctionGroup( ctx: Context, r: number, c: number, - id?: string + id?: string, + calcChainSet?: Set ) { if (_.isNil(id)) { id = ctx.currentSheetId; @@ -971,14 +972,18 @@ export function insertUpdateFunctionGroup( calcChain = []; } - for (let i = 0; i < calcChain.length; i += 1) { - const calc = calcChain[i]; - if (calc.r === r && calc.c === c && calc.id === id) { - // server.saveParam("fc", index, calc, { - // op: "update", - // pos: i, - // }); - return; + if (calcChainSet) { + if (calcChainSet.has(`${r}_${c}_${id}`)) return; + } else { + for (let i = 0; i < calcChain.length; i += 1) { + const calc = calcChain[i]; + if (calc.r === r && calc.c === c && calc.id === id) { + // server.saveParam("fc", index, calc, { + // op: "update", + // pos: i, + // }); + return; + } } } @@ -1003,6 +1008,7 @@ export function execfunction( r: number, c: number, id?: string, + calcChainSet?: Set, isrefresh?: boolean, notInsertFunc?: boolean ) { @@ -1162,7 +1168,7 @@ export function execfunction( } if (!notInsertFunc) { - insertUpdateFunctionGroup(ctx, r, c, id); + insertUpdateFunctionGroup(ctx, r, c, id, calcChainSet); } } @@ -1640,6 +1646,11 @@ export function execFunctionGroup( formulaRunList.reverse(); + const calcChainSet = new Set(); + calcChains.forEach((item) => { + calcChainSet.add(`${item.r}_${item.c}_${item.id}`); + }); + // console.log(formulaObjects, ii) // console.timeEnd("3"); @@ -1657,7 +1668,8 @@ export function execFunctionGroup( calc_funcStr, formulaCell.r, formulaCell.c, - formulaCell.id + formulaCell.id, + calcChainSet ); ctx.groupValuesRefreshData.push({