Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix(formula): skip tree after add to formula run list (#3114)

Dushusira238ea964b96
diff --git a/packages/core/src/services/snapshot/snapshot-transform.ts b/packages/core/src/services/snapshot/snapshot-transform.ts
index e83930658f..2dd06af03d 100644
--- a/packages/core/src/services/snapshot/snapshot-transform.ts
+++ b/packages/core/src/services/snapshot/snapshot-transform.ts
@@ -89,7 +89,7 @@ export async function generateTemporarySnap(
// Trigger RPC and store the result in sheetBlocks.
if (worksheet.cellData) {
- const sheetBlocks = splitCellDataToBlocks(worksheet.cellData, worksheet.rowCount!);
+ const sheetBlocks = splitCellDataToBlocks(worksheet.cellData, worksheet.columnCount!);
const responses = await Promise.all(
sheetBlocks.map((block) =>
snapshotService.saveSheetBlock(context, {
@@ -174,7 +174,7 @@ export async function transformWorkbookDataToSnapshot(
// Trigger RPC and store the result in sheetBlocks.
if (worksheet.cellData) {
- const sheetBlocks = splitCellDataToBlocks(worksheet.cellData, worksheet.rowCount!);
+ const sheetBlocks = splitCellDataToBlocks(worksheet.cellData, worksheet.columnCount!);
const responses = await Promise.all(
sheetBlocks.map((block) =>
snapshotService.saveSheetBlock(context, {
diff --git a/packages/engine-formula/src/engine/dependency/formula-dependency.ts b/packages/engine-formula/src/engine/dependency/formula-dependency.ts
index e8905107ff..c50392e3fe 100644
--- a/packages/engine-formula/src/engine/dependency/formula-dependency.ts
+++ b/packages/engine-formula/src/engine/dependency/formula-dependency.ts
@@ -858,6 +858,9 @@ export class FormulaDependencyGenerator extends Disposable {
if (tree.isAdded()) {
formulaRunList.push(tree);
+ // If cacheStack is empty, that is, all parent nodes of the node have been processed, call setSkip() to mark the node as skipped. The premise of this is that the node should have been added to the formulaRunList, that is, the calculation is completed.
+ // Make sure setSkip is called after the node is added to formulaRunList to avoid skipping processing early.
+ tree.setSkip();
continue;
}