fix(formula): start calculation trigger (#6321)

This commit is contained in:
Univer
2025-12-16 21:03:01 +08:00
committed by GitHub
parent a1b7d95b65
commit e52201a7d7
23 changed files with 78 additions and 44 deletions
@@ -77,6 +77,12 @@ export const SetFormulaCalculationStartMutation: IMutation<ISetFormulaCalculatio
handler: () => true,
};
export const SetTriggerFormulaCalculationStartMutation: IMutation<ISetFormulaCalculationStartMutation> = {
id: 'formula.mutation.set-trigger-formula-calculation-start',
type: CommandType.MUTATION,
handler: () => true,
};
export const SetFormulaStringBatchCalculationMutation: IMutation<ISetFormulaStringBatchCalculationMutation> = {
id: 'formula.mutation.set-formula-string-batch-calculation',
type: CommandType.MUTATION,
@@ -37,6 +37,7 @@ import {
SetFormulaStringBatchCalculationResultMutation,
SetQueryFormulaDependencyMutation,
SetQueryFormulaDependencyResultMutation,
SetTriggerFormulaCalculationStartMutation,
} from '../commands/mutations/set-formula-calculation.mutation';
import { SetFormulaDataMutation } from '../commands/mutations/set-formula-data.mutation';
import { SetImageFormulaDataMutation } from '../commands/mutations/set-image-formula-data.mutation';
@@ -84,6 +85,7 @@ export class FormulaController extends Disposable {
SetArrayFormulaDataMutation,
SetImageFormulaDataMutation,
SetFormulaCalculationStartMutation,
SetTriggerFormulaCalculationStartMutation,
SetFormulaStringBatchCalculationMutation,
SetFormulaStringBatchCalculationResultMutation,
SetQueryFormulaDependencyMutation,
@@ -18,7 +18,7 @@ import type { ICommandInfo, IDisposable, IUnitRange } from '@univerjs/core';
import type { FormulaExecutedStateType, IExecutionInProgressParams, IExprTreeNode, IFormulaDependencyTreeFullJson, IFormulaDependencyTreeJson, IFormulaExecuteResultMap, IFormulaStringMap, ISequenceNode, ISetCellFormulaDependencyCalculationResultMutation, ISetFormulaCalculationNotificationMutation, ISetFormulaCalculationResultMutation, ISetFormulaCalculationStartMutation, ISetFormulaDependencyCalculationResultMutation, ISetFormulaStringBatchCalculationResultMutation } from '@univerjs/engine-formula';
import { ICommandService, IConfigService, Inject, Injector } from '@univerjs/core';
import { FBase } from '@univerjs/core/facade';
import { ENGINE_FORMULA_CYCLE_REFERENCE_COUNT, ENGINE_FORMULA_RETURN_DEPENDENCY_TREE, GlobalComputingStatusService, IDefinedNamesService, IFunctionService, ISuperTableService, LexerTreeBuilder, SetCellFormulaDependencyCalculationMutation, SetCellFormulaDependencyCalculationResultMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation, SetFormulaDependencyCalculationMutation, SetFormulaDependencyCalculationResultMutation, SetFormulaStringBatchCalculationMutation, SetFormulaStringBatchCalculationResultMutation, SetQueryFormulaDependencyMutation, SetQueryFormulaDependencyResultMutation } from '@univerjs/engine-formula';
import { ENGINE_FORMULA_CYCLE_REFERENCE_COUNT, ENGINE_FORMULA_RETURN_DEPENDENCY_TREE, GlobalComputingStatusService, IDefinedNamesService, IFunctionService, ISuperTableService, LexerTreeBuilder, SetCellFormulaDependencyCalculationMutation, SetCellFormulaDependencyCalculationResultMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation, SetFormulaDependencyCalculationMutation, SetFormulaDependencyCalculationResultMutation, SetFormulaStringBatchCalculationMutation, SetFormulaStringBatchCalculationResultMutation, SetQueryFormulaDependencyMutation, SetQueryFormulaDependencyResultMutation, SetTriggerFormulaCalculationStartMutation } from '@univerjs/engine-formula';
import { filter, firstValueFrom, map, race, timer } from 'rxjs';
/**
@@ -100,7 +100,7 @@ export class FFormula extends FBase {
* ```
*/
executeCalculation(): void {
this._commandService.executeCommand(SetFormulaCalculationStartMutation.id, { commands: [], forceCalculation: true }, { onlyLocal: true });
this._commandService.executeCommand(SetTriggerFormulaCalculationStartMutation.id, { commands: [], forceCalculation: true }, { onlyLocal: true });
}
/**
+1
View File
@@ -75,6 +75,7 @@ export {
SetFormulaStringBatchCalculationResultMutation,
SetQueryFormulaDependencyMutation,
SetQueryFormulaDependencyResultMutation,
SetTriggerFormulaCalculationStartMutation,
} from './commands/mutations/set-formula-calculation.mutation';
export { type ISetFormulaDataMutationParams, SetFormulaDataMutation } from './commands/mutations/set-formula-data.mutation';
export { type ISetImageFormulaDataMutationParams, SetImageFormulaDataMutation } from './commands/mutations/set-image-formula-data.mutation';
@@ -21,6 +21,7 @@ import { createIdentifier, Disposable } from '@univerjs/core';
export interface IDirtyConversionManagerParams {
commandId: string;
getDirtyData: (command: ICommandInfo) => {
forceCalculation?: boolean;
dirtyRanges?: IUnitRange[];
dirtyNameMap?: IDirtyUnitSheetNameMap;
dirtyDefinedNameMap?: IDirtyUnitSheetDefinedNameMap;
@@ -18,7 +18,7 @@ import type { Injector } from '@univerjs/core';
import type { FUniver } from '@univerjs/core/facade';
import type { IUniverSheetsFormulaBaseConfig } from '@univerjs/sheets-formula';
import { ICommandService, IConfigService } from '@univerjs/core';
import { SetArrayFormulaDataMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation } from '@univerjs/engine-formula';
import { SetArrayFormulaDataMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation, SetTriggerFormulaCalculationStartMutation } from '@univerjs/engine-formula';
import { CalculationMode, PLUGIN_CONFIG_KEY_BASE } from '@univerjs/sheets-formula';
import { beforeEach, describe, expect, it } from 'vitest';
import { createFormulaTestBed } from './create-formula-test-bed';
@@ -35,6 +35,7 @@ describe('Test FFormula', () => {
commandService = get(ICommandService);
commandService.registerCommand(SetFormulaCalculationStartMutation);
commandService.registerCommand(SetTriggerFormulaCalculationStartMutation);
commandService.registerCommand(SetFormulaCalculationStopMutation);
commandService.registerCommand(SetFormulaCalculationNotificationMutation);
commandService.registerCommand(SetFormulaCalculationResultMutation);
@@ -15,7 +15,7 @@
*/
import type { ICellData, ICommandInfo, IObjectMatrixPrimitiveType, IRange, IUnitRange, Nullable } from '@univerjs/core';
import type { IDirtyUnitSheetDefinedNameMap, IDirtyUnitSheetNameMap, ISetDefinedNameMutationParam } from '@univerjs/engine-formula';
import type { IDirtyUnitSheetDefinedNameMap, IDirtyUnitSheetNameMap, IFormulaDirtyData, ISetDefinedNameMutationParam } from '@univerjs/engine-formula';
import type {
IInsertColMutationParams,
IInsertRowMutationParams,
@@ -37,7 +37,7 @@ import {
IUniverInstanceService,
ObjectMatrix,
} from '@univerjs/core';
import { FormulaDataModel, IActiveDirtyManagerService, RemoveDefinedNameMutation, SetDefinedNameMutation } from '@univerjs/engine-formula';
import { FormulaDataModel, IActiveDirtyManagerService, RemoveDefinedNameMutation, SetDefinedNameMutation, SetTriggerFormulaCalculationStartMutation } from '@univerjs/engine-formula';
import {
InsertColMutation,
InsertRowMutation,
@@ -255,6 +255,16 @@ export class ActiveDirtyController extends Disposable {
}
private _initialSheet() {
this._activeDirtyManagerService.register(SetTriggerFormulaCalculationStartMutation.id, {
commandId: SetTriggerFormulaCalculationStartMutation.id,
getDirtyData: (command: ICommandInfo) => {
const params = command.params as IFormulaDirtyData;
return {
...params,
};
},
});
this._activeDirtyManagerService.register(RemoveSheetMutation.id, {
commandId: RemoveSheetMutation.id,
getDirtyData: (command: ICommandInfo) => {
@@ -38,6 +38,7 @@ import {
SetFormulaCalculationStartMutation,
SetFormulaCalculationStopMutation,
SetFormulaStringBatchCalculationMutation,
SetTriggerFormulaCalculationStartMutation,
} from '@univerjs/engine-formula';
import {
ClearSelectionFormatCommand,
@@ -90,11 +91,6 @@ export class TriggerCalculationController extends Disposable {
private _restartCalculation = false;
/**
* The mark of forced calculation. If a new mutation triggers dirty area calculation during the forced calculation process, forced calculation is still required.
*/
private _forceCalculating = false;
private readonly _progress$ = new BehaviorSubject<ICalculationProgress>(NilProgress);
readonly progress$ = this._progress$.asObservable();
@@ -232,6 +228,7 @@ export class TriggerCalculationController extends Disposable {
const allDirtyUnitFeatureMap: IDirtyUnitFeatureMap = {};
const allDirtyUnitOtherFormulaMap: IDirtyUnitOtherFormulaMap = {};
const allClearDependencyTreeCache: IDirtyUnitSheetNameMap = {};
let allForceCalculation = false;
// const numfmtItemMap: INumfmtItemMap = Tools.deepClone(this._formulaDataModel.getNumfmtItemMap());
@@ -244,7 +241,7 @@ export class TriggerCalculationController extends Disposable {
const params = conversion.getDirtyData(command);
const { dirtyRanges, dirtyNameMap, dirtyDefinedNameMap, dirtyUnitFeatureMap, dirtyUnitOtherFormulaMap, clearDependencyTreeCache } = params;
const { dirtyRanges, dirtyNameMap, dirtyDefinedNameMap, dirtyUnitFeatureMap, dirtyUnitOtherFormulaMap, clearDependencyTreeCache, forceCalculation = false } = params;
if (dirtyRanges != null) {
this._mergeDirtyRanges(allDirtyRanges, dirtyRanges);
@@ -269,6 +266,8 @@ export class TriggerCalculationController extends Disposable {
if (clearDependencyTreeCache != null) {
this._mergeDirtyNameMap(allClearDependencyTreeCache, clearDependencyTreeCache);
}
allForceCalculation = allForceCalculation || forceCalculation;
}
return {
@@ -277,7 +276,7 @@ export class TriggerCalculationController extends Disposable {
dirtyDefinedNameMap: allDirtyDefinedNameMap,
dirtyUnitFeatureMap: allDirtyUnitFeatureMap,
dirtyUnitOtherFormulaMap: allDirtyUnitOtherFormulaMap,
forceCalculation: false,
forceCalculation: allForceCalculation,
clearDependencyTreeCache: allClearDependencyTreeCache,
// numfmtItemMap,
};
@@ -297,13 +296,15 @@ export class TriggerCalculationController extends Disposable {
this._mergeDirtyUnitFeatureOrOtherFormulaMap(allDirtyUnitOtherFormulaMap, dirtyData2.dirtyUnitOtherFormulaMap);
this._mergeDirtyNameMap(allClearDependencyTreeCache, dirtyData2.clearDependencyTreeCache);
const allForceCalculating = dirtyData1.forceCalculation || dirtyData2.forceCalculation;
return {
dirtyRanges: allDirtyRanges,
dirtyNameMap: allDirtyNameMap,
dirtyDefinedNameMap: allDirtyDefinedNameMap,
dirtyUnitFeatureMap: allDirtyUnitFeatureMap,
dirtyUnitOtherFormulaMap: allDirtyUnitOtherFormulaMap,
forceCalculation: !!this._forceCalculating,
forceCalculation: allForceCalculating,
clearDependencyTreeCache: allClearDependencyTreeCache,
};
}
@@ -383,13 +384,7 @@ export class TriggerCalculationController extends Disposable {
// eslint-disable-next-line max-lines-per-function, complexity
this._commandService.onCommandExecuted((command: ICommandInfo) => {
if (command.id === SetFormulaCalculationStartMutation.id) {
const { forceCalculation = false } = command.params as ISetFormulaCalculationStartMutation;
if (forceCalculation) {
this._forceCalculating = true;
}
} else if (command.id === SetFormulaCalculationStopMutation.id) {
if (command.id === SetFormulaCalculationStopMutation.id) {
this.clearProgress();
}
@@ -493,7 +488,6 @@ export class TriggerCalculationController extends Disposable {
calculationProcessCount = 0;
this._doneCalculationTaskCount = 0;
this._totalCalculationTaskCount = 0;
this._forceCalculating = false;
}
if (state === FormulaExecutedStateType.STOP_EXECUTION && this._restartCalculation) {
@@ -530,7 +524,7 @@ export class TriggerCalculationController extends Disposable {
private _initialExecuteFormula() {
const calculationMode = this._getCalculationMode();
const params = this._getDirtyDataByCalculationMode(calculationMode);
this._commandService.executeCommand(SetFormulaCalculationStartMutation.id, params, lo);
this._commandService.executeCommand(SetTriggerFormulaCalculationStartMutation.id, params, lo);
this._registerOtherFormulaService.calculateStarted$.next(true);
}
@@ -42,7 +42,7 @@ import {
Tools,
UniverInstanceType,
} from '@univerjs/core';
import { deserializeRangeWithSheetWithCache, ErrorType, FormulaDataModel, generateStringWithSequence, IDefinedNamesService, initSheetFormulaData, LexerTreeBuilder, sequenceNodeType, serializeRangeToRefString, SetArrayFormulaDataMutation, SetFormulaCalculationStartMutation, SetFormulaDataMutation } from '@univerjs/engine-formula';
import { deserializeRangeWithSheetWithCache, ErrorType, FormulaDataModel, generateStringWithSequence, IDefinedNamesService, initSheetFormulaData, LexerTreeBuilder, sequenceNodeType, serializeRangeToRefString, SetArrayFormulaDataMutation, SetFormulaDataMutation, SetTriggerFormulaCalculationStartMutation } from '@univerjs/engine-formula';
import {
ClearSelectionFormatCommand,
InsertSheetMutation,
@@ -271,7 +271,7 @@ export class UpdateFormulaController extends Disposable {
const calculationMode = config?.initialFormulaComputing ?? CalculationMode.WHEN_EMPTY;
const params = this._getDirtyDataByCalculationMode(calculationMode);
this._commandService.executeCommand(SetFormulaCalculationStartMutation.id, params, { onlyLocal: true });
this._commandService.executeCommand(SetTriggerFormulaCalculationStartMutation.id, params, { onlyLocal: true });
}
private _getDirtyDataByCalculationMode(calculationMode: CalculationMode): IFormulaDirtyData {
@@ -19,7 +19,7 @@ import type { IDisposable, ILocales } from '@univerjs/core';
import type { IFunctionInfo } from '@univerjs/engine-formula';
import type { CalculationMode, IRegisterAsyncFunction, IRegisterFunction, ISingleFunctionRegisterParams, IUniverSheetsFormulaBaseConfig } from '@univerjs/sheets-formula';
import { debounce, IConfigService, ILogService, LifecycleService, LifecycleStages } from '@univerjs/core';
import { SetFormulaCalculationStartMutation } from '@univerjs/engine-formula';
import { SetTriggerFormulaCalculationStartMutation } from '@univerjs/engine-formula';
import { FFormula } from '@univerjs/engine-formula/facade';
import { IRegisterFunctionService, PLUGIN_CONFIG_KEY_BASE, RegisterFunctionService } from '@univerjs/sheets-formula';
@@ -286,7 +286,7 @@ export class FFormulaSheetsMixin extends FFormula implements IFFormulaSheetsMixi
override _initialize(): void {
this._debouncedFormulaCalculation = debounce(() => {
this._commandService.executeCommand(
SetFormulaCalculationStartMutation.id,
SetTriggerFormulaCalculationStartMutation.id,
{
commands: [],
forceCalculation: true,
@@ -18,7 +18,7 @@ import type { IDisposable } from '@univerjs/core';
import type { IRegisterFunctionParams } from '@univerjs/sheets-formula';
import { debounce } from '@univerjs/core';
import { FUniver } from '@univerjs/core/facade';
import { SetFormulaCalculationStartMutation } from '@univerjs/engine-formula';
import { SetTriggerFormulaCalculationStartMutation } from '@univerjs/engine-formula';
import { IRegisterFunctionService, RegisterFunctionService } from '@univerjs/sheets-formula';
/**
@@ -50,7 +50,7 @@ export class FUniverSheetsFormulaMixin extends FUniver implements IFUniverSheets
override _initialize(): void {
this._debouncedFormulaCalculation = debounce(() => {
this._commandService.executeCommand(
SetFormulaCalculationStartMutation.id,
SetTriggerFormulaCalculationStartMutation.id,
{
commands: [],
forceCalculation: true,
@@ -18,7 +18,7 @@ import type { CellValue, Ctor, Injector, IWorkbookData, Nullable, Worksheet } fr
import type { BaseFunction, IFunctionNames } from '@univerjs/engine-formula';
import type { FFormula } from '@univerjs/engine-formula/facade';
import { ICommandService, LocaleType } from '@univerjs/core';
import { functionLogical, functionLookup, functionMath, functionMeta, functionStatistical, IFormulaCurrentConfigService, IFormulaRuntimeService, IFunctionService, SetArrayFormulaDataMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation } from '@univerjs/engine-formula';
import { functionLogical, functionLookup, functionMath, functionMeta, functionStatistical, IFormulaCurrentConfigService, IFormulaRuntimeService, IFunctionService, SetArrayFormulaDataMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation, SetTriggerFormulaCalculationStartMutation } from '@univerjs/engine-formula';
import { beforeEach, describe, expect, it } from 'vitest';
import { SetRangeValuesMutation } from '../../../commands/mutations/set-range-values.mutation';
import { createFunctionTestBed } from './create-function-test-bed';
@@ -361,6 +361,7 @@ describe('Test AGGREGATE formula', () => {
commandService = get(ICommandService);
commandService.registerCommand(SetFormulaCalculationStartMutation);
commandService.registerCommand(SetTriggerFormulaCalculationStartMutation);
commandService.registerCommand(SetFormulaCalculationStopMutation);
commandService.registerCommand(SetFormulaCalculationResultMutation);
commandService.registerCommand(SetFormulaCalculationNotificationMutation);
@@ -418,7 +419,7 @@ describe('Test AGGREGATE formula', () => {
...functions
);
formulaEngine.executeCalculation();
commandService.syncExecuteCommand(SetFormulaCalculationStartMutation.id, { forceCalculation: true }, { onlyLocal: true });
await formulaEngine.onCalculationEnd();
getCellValue = (row: number, column: number) => {
@@ -18,7 +18,7 @@ import type { CellValue, Ctor, Injector, IWorkbookData, Nullable, Worksheet } fr
import type { BaseFunction, IFunctionNames } from '@univerjs/engine-formula';
import type { FFormula } from '@univerjs/engine-formula/facade';
import { ICommandService, LocaleType } from '@univerjs/core';
import { functionLogical, functionLookup, functionMath, functionMeta, functionStatistical, IFormulaCurrentConfigService, IFormulaRuntimeService, IFunctionService, SetArrayFormulaDataMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation } from '@univerjs/engine-formula';
import { functionLogical, functionLookup, functionMath, functionMeta, functionStatistical, IFormulaCurrentConfigService, IFormulaRuntimeService, IFunctionService, SetArrayFormulaDataMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation, SetTriggerFormulaCalculationStartMutation } from '@univerjs/engine-formula';
import { beforeEach, describe, expect, it } from 'vitest';
import { SetRangeValuesMutation } from '../../../commands/mutations/set-range-values.mutation';
import { createFunctionTestBed } from './create-function-test-bed';
@@ -3339,6 +3339,7 @@ describe('Test AGGREGATE formula 2', () => {
commandService = get(ICommandService);
commandService.registerCommand(SetFormulaCalculationStartMutation);
commandService.registerCommand(SetTriggerFormulaCalculationStartMutation);
commandService.registerCommand(SetFormulaCalculationStopMutation);
commandService.registerCommand(SetFormulaCalculationResultMutation);
commandService.registerCommand(SetFormulaCalculationNotificationMutation);
@@ -3396,7 +3397,7 @@ describe('Test AGGREGATE formula 2', () => {
...functions
);
formulaEngine.executeCalculation();
commandService.syncExecuteCommand(SetFormulaCalculationStartMutation.id, { forceCalculation: true }, { onlyLocal: true });
await formulaEngine.onCalculationEnd();
getCellValue = (row: number, column: number) => {
@@ -18,7 +18,7 @@ import type { CellValue, Ctor, Injector, IWorkbookData, Nullable, Worksheet } fr
import type { BaseFunction, IFunctionNames } from '@univerjs/engine-formula';
import type { FFormula } from '@univerjs/engine-formula/facade';
import { ICommandService, LocaleType } from '@univerjs/core';
import { functionLogical, functionLookup, functionMath, functionMeta, functionStatistical, IFormulaCurrentConfigService, IFormulaRuntimeService, IFunctionService, SetArrayFormulaDataMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation } from '@univerjs/engine-formula';
import { functionLogical, functionLookup, functionMath, functionMeta, functionStatistical, IFormulaCurrentConfigService, IFormulaRuntimeService, IFunctionService, SetArrayFormulaDataMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation, SetTriggerFormulaCalculationStartMutation } from '@univerjs/engine-formula';
import { beforeEach, describe, expect, it } from 'vitest';
import { SetRangeValuesMutation } from '../../../commands/mutations/set-range-values.mutation';
import { createFunctionTestBed } from './create-function-test-bed';
@@ -199,6 +199,7 @@ describe('Test AGGREGATE formula 3', () => {
commandService = get(ICommandService);
commandService.registerCommand(SetFormulaCalculationStartMutation);
commandService.registerCommand(SetTriggerFormulaCalculationStartMutation);
commandService.registerCommand(SetFormulaCalculationStopMutation);
commandService.registerCommand(SetFormulaCalculationResultMutation);
commandService.registerCommand(SetFormulaCalculationNotificationMutation);
@@ -256,7 +257,7 @@ describe('Test AGGREGATE formula 3', () => {
...functions
);
formulaEngine.executeCalculation();
commandService.syncExecuteCommand(SetFormulaCalculationStartMutation.id, { forceCalculation: true }, { onlyLocal: true });
await formulaEngine.onCalculationEnd();
getCellValue = (row: number, column: number) => {
@@ -35,6 +35,7 @@ import {
SetFormulaCalculationResultMutation,
SetFormulaCalculationStartMutation,
SetFormulaCalculationStopMutation,
SetTriggerFormulaCalculationStartMutation,
} from '@univerjs/engine-formula';
import { beforeEach, describe, expect, it } from 'vitest';
import { SetRangeValuesMutation } from '../../../commands/mutations/set-range-values.mutation';
@@ -243,6 +244,7 @@ describe('Test inverted index cache 1', () => {
commandService = get(ICommandService);
commandService.registerCommand(SetFormulaCalculationStartMutation);
commandService.registerCommand(SetTriggerFormulaCalculationStartMutation);
commandService.registerCommand(SetFormulaCalculationStopMutation);
commandService.registerCommand(SetFormulaCalculationResultMutation);
commandService.registerCommand(SetFormulaCalculationNotificationMutation);
@@ -299,7 +301,7 @@ describe('Test inverted index cache 1', () => {
...functions
);
formulaEngine.executeCalculation();
commandService.syncExecuteCommand(SetFormulaCalculationStartMutation.id, { forceCalculation: true }, { onlyLocal: true });
await formulaEngine.onCalculationEnd();
getCellValue = (row: number, column: number) => {
@@ -335,7 +337,7 @@ describe('Test inverted index cache 1', () => {
},
},
});
formulaEngine.executeCalculation();
commandService.syncExecuteCommand(SetFormulaCalculationStartMutation.id, { forceCalculation: true }, { onlyLocal: true });
await formulaEngine.onCalculationEnd();
// now result should be 1
@@ -33,6 +33,7 @@ import {
SetFormulaCalculationResultMutation,
SetFormulaCalculationStartMutation,
SetFormulaCalculationStopMutation,
SetTriggerFormulaCalculationStartMutation,
} from '@univerjs/engine-formula';
import { beforeEach, describe, expect, it } from 'vitest';
import { SetRangeValuesMutation } from '../../../commands/mutations/set-range-values.mutation';
@@ -178,6 +179,7 @@ describe('Test inverted index cache 2', () => {
commandService = get(ICommandService);
commandService.registerCommand(SetFormulaCalculationStartMutation);
commandService.registerCommand(SetTriggerFormulaCalculationStartMutation);
commandService.registerCommand(SetFormulaCalculationStopMutation);
commandService.registerCommand(SetFormulaCalculationResultMutation);
commandService.registerCommand(SetFormulaCalculationNotificationMutation);
@@ -31,6 +31,7 @@ import {
SetFormulaCalculationResultMutation,
SetFormulaCalculationStartMutation,
SetFormulaCalculationStopMutation,
SetTriggerFormulaCalculationStartMutation,
} from '@univerjs/engine-formula';
import { beforeEach, describe, expect, it } from 'vitest';
import { SetRangeValuesMutation } from '../../../commands/mutations/set-range-values.mutation';
@@ -195,6 +196,7 @@ describe('Test inverted index cache 3', () => {
commandService = get(ICommandService);
commandService.registerCommand(SetFormulaCalculationStartMutation);
commandService.registerCommand(SetTriggerFormulaCalculationStartMutation);
commandService.registerCommand(SetFormulaCalculationStopMutation);
commandService.registerCommand(SetFormulaCalculationResultMutation);
commandService.registerCommand(SetFormulaCalculationNotificationMutation);
@@ -251,7 +253,7 @@ describe('Test inverted index cache 3', () => {
...functions
);
formulaEngine.executeCalculation();
commandService.syncExecuteCommand(SetFormulaCalculationStartMutation.id, { forceCalculation: true }, { onlyLocal: true });
await formulaEngine.onCalculationEnd();
getCellValue = (row: number, column: number) => {
@@ -31,6 +31,7 @@ import {
SetFormulaCalculationResultMutation,
SetFormulaCalculationStartMutation,
SetFormulaCalculationStopMutation,
SetTriggerFormulaCalculationStartMutation,
} from '@univerjs/engine-formula';
import { beforeEach, describe, expect, it } from 'vitest';
import { SetRangeValuesMutation } from '../../../commands/mutations/set-range-values.mutation';
@@ -140,6 +141,7 @@ describe('Test inverted index cache 4', () => {
commandService = get(ICommandService);
commandService.registerCommand(SetFormulaCalculationStartMutation);
commandService.registerCommand(SetTriggerFormulaCalculationStartMutation);
commandService.registerCommand(SetFormulaCalculationStopMutation);
commandService.registerCommand(SetFormulaCalculationResultMutation);
commandService.registerCommand(SetFormulaCalculationNotificationMutation);
@@ -196,7 +198,7 @@ describe('Test inverted index cache 4', () => {
...functions
);
formulaEngine.executeCalculation();
commandService.syncExecuteCommand(SetFormulaCalculationStartMutation.id, { forceCalculation: true }, { onlyLocal: true });
await formulaEngine.onCalculationEnd();
getCellValue = (row: number, column: number) => {
@@ -29,6 +29,7 @@ import {
SetFormulaCalculationResultMutation,
SetFormulaCalculationStartMutation,
SetFormulaCalculationStopMutation,
SetTriggerFormulaCalculationStartMutation,
} from '@univerjs/engine-formula';
import { beforeEach, describe, expect, it } from 'vitest';
import { SetRangeValuesMutation } from '../../../commands/mutations/set-range-values.mutation';
@@ -1790,6 +1791,7 @@ describe('Test inverted index cache 5', () => {
commandService = get(ICommandService);
commandService.registerCommand(SetFormulaCalculationStartMutation);
commandService.registerCommand(SetTriggerFormulaCalculationStartMutation);
commandService.registerCommand(SetFormulaCalculationStopMutation);
commandService.registerCommand(SetFormulaCalculationResultMutation);
commandService.registerCommand(SetFormulaCalculationNotificationMutation);
@@ -1844,7 +1846,7 @@ describe('Test inverted index cache 5', () => {
...functions
);
formulaEngine.executeCalculation();
commandService.syncExecuteCommand(SetFormulaCalculationStartMutation.id, { forceCalculation: true }, { onlyLocal: true });
await formulaEngine.onCalculationEnd();
getCellValue = (row: number, column: number) => {
@@ -18,7 +18,7 @@ import type { CellValue, CellValueType, Ctor, Injector, IWorkbookData, Nullable,
import type { BaseFunction, IFunctionNames } from '@univerjs/engine-formula';
import type { FFormula } from '@univerjs/engine-formula/facade';
import { ICommandService, LocaleType } from '@univerjs/core';
import { FormulaDataModel, functionMeta, IFormulaCurrentConfigService, IFormulaRuntimeService, IFunctionService, SetArrayFormulaDataMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation } from '@univerjs/engine-formula';
import { FormulaDataModel, functionMeta, IFormulaCurrentConfigService, IFormulaRuntimeService, IFunctionService, SetArrayFormulaDataMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation, SetTriggerFormulaCalculationStartMutation } from '@univerjs/engine-formula';
import { beforeEach, describe, expect, it } from 'vitest';
import { SetRangeValuesMutation } from '../../../commands/mutations/set-range-values.mutation';
import { createFunctionTestBed } from './create-function-test-bed';
@@ -326,6 +326,7 @@ describe('Test inverted index cache 6', () => {
commandService = get(ICommandService);
commandService.registerCommand(SetFormulaCalculationStartMutation);
commandService.registerCommand(SetTriggerFormulaCalculationStartMutation);
commandService.registerCommand(SetFormulaCalculationStopMutation);
commandService.registerCommand(SetFormulaCalculationResultMutation);
commandService.registerCommand(SetFormulaCalculationNotificationMutation);
@@ -379,7 +380,7 @@ describe('Test inverted index cache 6', () => {
...functions
);
formulaEngine.executeCalculation();
commandService.syncExecuteCommand(SetFormulaCalculationStartMutation.id, { forceCalculation: true }, { onlyLocal: true });
await formulaEngine.onCalculationEnd();
getArrayFormulaResult = (row: number, column: number) => {
@@ -33,6 +33,7 @@ import {
SetFormulaCalculationResultMutation,
SetFormulaCalculationStartMutation,
SetFormulaCalculationStopMutation,
SetTriggerFormulaCalculationStartMutation,
} from '@univerjs/engine-formula';
import { beforeEach, describe, expect, it } from 'vitest';
import { SetRangeValuesMutation } from '../../../commands/mutations/set-range-values.mutation';
@@ -147,6 +148,7 @@ describe('Test inverted index cache', () => {
commandService = get(ICommandService);
commandService.registerCommand(SetFormulaCalculationStartMutation);
commandService.registerCommand(SetTriggerFormulaCalculationStartMutation);
commandService.registerCommand(SetFormulaCalculationStopMutation);
commandService.registerCommand(SetFormulaCalculationResultMutation);
commandService.registerCommand(SetFormulaCalculationNotificationMutation);
@@ -201,7 +203,7 @@ describe('Test inverted index cache', () => {
...functions
);
formulaEngine.executeCalculation();
commandService.syncExecuteCommand(SetFormulaCalculationStartMutation.id, { forceCalculation: true }, { onlyLocal: true });
await formulaEngine.onCalculationEnd();
getCellValue = (row: number, column: number) => {
@@ -17,7 +17,7 @@
import type { Ctor, Injector, IWorkbookData } from '@univerjs/core';
import type { BaseAstNode, BaseFunction, IFunctionNames, LexerNode } from '@univerjs/engine-formula';
import { ICommandService, LocaleType } from '@univerjs/core';
import { AstTreeBuilder, ErrorType, functionLookup, functionMath, functionMeta, functionStatistical, generateExecuteAstNodeData, getObjectValue, IFormulaCurrentConfigService, IFormulaRuntimeService, IFunctionService, Interpreter, Lexer, SetArrayFormulaDataMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation } from '@univerjs/engine-formula';
import { AstTreeBuilder, ErrorType, functionLookup, functionMath, functionMeta, functionStatistical, generateExecuteAstNodeData, getObjectValue, IFormulaCurrentConfigService, IFormulaRuntimeService, IFunctionService, Interpreter, Lexer, SetArrayFormulaDataMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation, SetTriggerFormulaCalculationStartMutation } from '@univerjs/engine-formula';
import { beforeEach, describe, expect, it } from 'vitest';
import { SetRangeValuesMutation } from '../../../commands/mutations/set-range-values.mutation';
import { createFunctionTestBed } from './create-function-test-bed';
@@ -1015,6 +1015,7 @@ describe('Test SUBTOTAL formula', () => {
commandService = get(ICommandService);
commandService.registerCommand(SetFormulaCalculationStartMutation);
commandService.registerCommand(SetTriggerFormulaCalculationStartMutation);
commandService.registerCommand(SetFormulaCalculationStopMutation);
commandService.registerCommand(SetFormulaCalculationResultMutation);
commandService.registerCommand(SetFormulaCalculationNotificationMutation);
@@ -35,6 +35,7 @@ import {
SetFormulaCalculationResultMutation,
SetFormulaCalculationStartMutation,
SetFormulaCalculationStopMutation,
SetTriggerFormulaCalculationStartMutation,
} from '@univerjs/engine-formula';
import { beforeEach, describe, expect, it } from 'vitest';
import { SetRangeValuesMutation } from '../../../commands/mutations/set-range-values.mutation';
@@ -391,6 +392,7 @@ describe('Test inverted index cache', () => {
commandService = get(ICommandService);
commandService.registerCommand(SetFormulaCalculationStartMutation);
commandService.registerCommand(SetTriggerFormulaCalculationStartMutation);
commandService.registerCommand(SetFormulaCalculationStopMutation);
commandService.registerCommand(SetFormulaCalculationResultMutation);
commandService.registerCommand(SetFormulaCalculationNotificationMutation);
@@ -447,7 +449,7 @@ describe('Test inverted index cache', () => {
...functions
);
formulaEngine.executeCalculation();
commandService.syncExecuteCommand(SetFormulaCalculationStartMutation.id, { forceCalculation: true }, { onlyLocal: true });
await formulaEngine.onCalculationEnd();
getCellValue = (subUnitId: string, row: number, column: number) => {