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: incorrectly quit autofill mode (#3390)

YuHongf0fc942c5715
diff --git a/packages/sheets-formula/src/controllers/update-formula.controller.ts b/packages/sheets-formula/src/controllers/update-formula.controller.ts
index acf1943cb9..d69c14db41 100644
--- a/packages/sheets-formula/src/controllers/update-formula.controller.ts
+++ b/packages/sheets-formula/src/controllers/update-formula.controller.ts
@@ -14,16 +14,6 @@
* limitations under the License.
*/
-import type {
- DocumentDataModel,
- ICommandInfo,
- IExecutionOptions,
- IRange,
- IUnitRange,
- Nullable,
- SlideDataModel,
- Workbook,
-} from '@univerjs/core';
import {
Direction,
Disposable,
@@ -40,7 +30,6 @@ import {
Tools,
UniverInstanceType,
} from '@univerjs/core';
-import type { IFormulaData, IFormulaDataItem, ISequenceNode, IUnitSheetNameMap } from '@univerjs/engine-formula';
import { deserializeRangeWithSheet,
ErrorType,
FormulaDataModel,
@@ -53,24 +42,6 @@ import { deserializeRangeWithSheet,
SetFormulaCalculationStartMutation,
SetFormulaDataMutation,
} from '@univerjs/engine-formula';
-
-import type {
- IDeleteRangeMoveLeftCommandParams,
- IDeleteRangeMoveUpCommandParams,
- IInsertColCommandParams,
- IInsertRowCommandParams,
- IInsertSheetMutationParams,
- IMoveColsCommandParams,
- IMoveRangeCommandParams,
- IMoveRowsCommandParams,
- InsertRangeMoveDownCommandParams,
- InsertRangeMoveRightCommandParams,
- IRemoveRowColCommandParams,
- IRemoveSheetCommandParams,
- IRemoveSheetMutationParams,
- ISetRangeValuesMutationParams,
- ISetWorksheetNameCommandParams,
-} from '@univerjs/sheets';
import {
ClearSelectionFormatCommand,
DeleteRangeMoveLeftCommand,
@@ -106,9 +77,38 @@ import {
SheetInterceptorService,
SheetsSelectionsService,
} from '@univerjs/sheets';
+import { IEditorService } from '@univerjs/ui';
import { filter, map, merge } from 'rxjs';
-import { IEditorService } from '@univerjs/ui';
+import type {
+ DocumentDataModel,
+ ICommandInfo,
+ IExecutionOptions,
+ IRange,
+ IUnitRange,
+ Nullable,
+ SlideDataModel,
+ Workbook,
+} from '@univerjs/core';
+
+import type { IFormulaData, IFormulaDataItem, ISequenceNode, IUnitSheetNameMap } from '@univerjs/engine-formula';
+import type {
+ IDeleteRangeMoveLeftCommandParams,
+ IDeleteRangeMoveUpCommandParams,
+ IInsertColCommandParams,
+ IInsertRowCommandParams,
+ IInsertSheetMutationParams,
+ IMoveColsCommandParams,
+ IMoveRangeCommandParams,
+ IMoveRowsCommandParams,
+ InsertRangeMoveDownCommandParams,
+ InsertRangeMoveRightCommandParams,
+ IRemoveRowColCommandParams,
+ IRemoveSheetCommandParams,
+ IRemoveSheetMutationParams,
+ ISetRangeValuesMutationParams,
+ ISetWorksheetNameCommandParams,
+} from '@univerjs/sheets';
import { removeFormulaData } from './utils/offset-formula-data';
import { formulaDataToCellData, getFormulaReferenceMoveUndoRedo } from './utils/ref-range-formula';
@@ -266,6 +266,7 @@ export class UpdateFormulaController extends Disposable {
},
{
onlyLocal: true,
+ fromFormula: true,
}
);
diff --git a/packages/sheets-ui/src/controllers/auto-fill.controller.ts b/packages/sheets-ui/src/controllers/auto-fill.controller.ts
index b9a8d44b65..22d9b17c04 100644
--- a/packages/sheets-ui/src/controllers/auto-fill.controller.ts
+++ b/packages/sheets-ui/src/controllers/auto-fill.controller.ts
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import type { IAccessor, ICellData, ICommandInfo, IExecutionOptions, IMutationCommonParams, IMutationInfo, IRange, Nullable, UnitModel, Workbook } from '@univerjs/core';
import {
Direction,
Disposable,
@@ -33,12 +32,6 @@ import {
UniverInstanceType,
} from '@univerjs/core';
import { DeviceInputEventType, IRenderManagerService } from '@univerjs/engine-render';
-import type {
- IAddWorksheetMergeMutationParams,
- IRemoveSheetMutationParams,
- IRemoveWorksheetMergeMutationParams,
- ISetRangeValuesMutationParams,
-} from '@univerjs/sheets';
import {
AddMergeUndoMutationFactory,
AddWorksheetMergeMutation,
@@ -61,11 +54,25 @@ import {
SetWorksheetColWidthMutation,
SetWorksheetRowHeightMutation,
} from '@univerjs/sheets';
+import type { IAccessor, ICellData, ICommandInfo, IExecutionOptions, IMutationCommonParams, IMutationInfo, IRange, Nullable, UnitModel, Workbook } from '@univerjs/core';
+import type {
+ IAddWorksheetMergeMutationParams,
+ IRemoveSheetMutationParams,
+ IRemoveWorksheetMergeMutationParams,
+ ISetRangeValuesMutationParams,
+} from '@univerjs/sheets';
import { AutoClearContentCommand, AutoFillCommand } from '../commands/commands/auto-fill.command';
+import { SetCellEditVisibleOperation } from '../commands/operations/cell-edit.operation';
+import { SetZoomRatioOperation } from '../commands/operations/set-zoom-ratio.operation';
import { IAutoFillService } from '../services/auto-fill/auto-fill.service';
import { otherRule } from '../services/auto-fill/rules';
import { fillCopy, fillCopyStyles, getDataIndex, getLenS } from '../services/auto-fill/tools';
+import { APPLY_TYPE, AutoFillHookType, DATA_TYPE } from '../services/auto-fill/type';
+import { IEditorBridgeService } from '../services/editor-bridge.service';
+import { ISheetSelectionRenderService } from '../services/selection/base-selection-render.service';
+import { SheetsRenderService } from '../services/sheets-render.service';
+import { discreteRangeToRange, generateNullCellValueRowCol, rangeToDiscreteRange } from './utils/range-tools';
import type {
APPLY_FUNCTIONS,
IAutoFillLocation,
@@ -74,14 +81,7 @@ import type {
IRuleConfirmedData,
ISheetAutoFillHook,
} from '../services/auto-fill/type';
-import { APPLY_TYPE, AutoFillHookType, DATA_TYPE } from '../services/auto-fill/type';
-import { IEditorBridgeService } from '../services/editor-bridge.service';
-import { SetCellEditVisibleOperation } from '../commands/operations/cell-edit.operation';
-import { SetZoomRatioOperation } from '../commands/operations/set-zoom-ratio.operation';
-import { SheetsRenderService } from '../services/sheets-render.service';
-import { ISheetSelectionRenderService } from '../services/selection/base-selection-render.service';
import type { IDiscreteRange } from './utils/range-tools';
-import { discreteRangeToRange, generateNullCellValueRowCol, rangeToDiscreteRange } from './utils/range-tools';
@OnLifecycle(LifecycleStages.Steady, AutoFillController)
export class AutoFillController extends Disposable {
@@ -152,9 +152,11 @@ export class AutoFillController extends Disposable {
this.disposeWithMe(this._commandService.onCommandExecuted((command: ICommandInfo, options?: IExecutionOptions) => {
const fromCollab = options?.fromCollab;
const fromSync = options?.fromSync;
+ const fromFormula = options?.fromFormula;
if (quitCommands.includes(command.id)
&& !fromCollab
&& !fromSync
+ && !fromFormula
&& (command.params as IMutationCommonParams).trigger !== AutoFillCommand.id
) {
this._quit();