fix: optimize auto row height recalculation when clearing cell content or styles (#6870)

This commit is contained in:
wpxp123456
2026-05-07 16:24:23 +08:00
committed by GitHub
parent 4055e42530
commit ef636900b6
31 changed files with 177 additions and 90 deletions
@@ -194,11 +194,11 @@ describe('LocalUndoRedoService', () => {
id: 'fail',
});
expect(commandService.syncExecuteCommand(UndoCommandId)).toBe(true);
expect(undoRedoService.pitchTopUndoElement()).toBeNull();
expect(undoRedoService.pitchTopRedoElement()?.id).toBe('fail');
expect(commandService.syncExecuteCommand(UndoCommandId)).toBe(false);
expect(undoRedoService.pitchTopUndoElement()?.id).toBe('fail');
expect(undoRedoService.pitchTopRedoElement()).toBeNull();
expect(commandService.syncExecuteCommand(RedoCommandId)).toBe(true);
expect(commandService.syncExecuteCommand(RedoCommandId)).toBe(false);
expect(undoRedoService.pitchTopRedoElement()).toBeNull();
expect(undoRedoService.pitchTopUndoElement()?.id).toBe('fail');
@@ -128,7 +128,7 @@ export const UndoCommand = new (class extends MultiImplementationCommand impleme
const commandService = accessor.get(ICommandService);
const result = sequenceExecute(element.undoMutations, commandService);
if (result) {
if (result.result) {
undoRedoService.popUndoToRedo();
return true;
@@ -152,7 +152,7 @@ export const RedoCommand = new (class extends MultiImplementationCommand impleme
const commandService = accessor.get(ICommandService);
const result = sequenceExecute(element.redoMutations, commandService);
if (result) {
if (result.result) {
undoRedoService.popRedoToUndo();
return true;
@@ -132,6 +132,7 @@ function createLocalSheetsTestBed(workbookData?: IWorkbookData, dependencies?: D
dependencies?.forEach((dependency) => injector.add(dependency));
injector.get(SheetInterceptorService);
injector.get(SheetSkeletonService);
injector.get(WorkbookPermissionService);
injector.get(WorksheetPermissionService);
}
@@ -155,7 +155,7 @@ export const FlipSheetDrawingCommand: ICommand = {
const result = sequenceExecute([updateMutation], commandService);
if (result) {
if (result.result) {
undoRedoService.pushUndoRedo({
unitID: opUnitId,
undoMutations: [undoUpdateMutation, { id: ClearSheetDrawingTransformerOperation.id, params: unitIds }],
@@ -32,6 +32,7 @@ import {
UniverInstanceType,
} from '@univerjs/core';
import { DrawingManagerService, IDrawingManagerService } from '@univerjs/drawing';
import { IRenderManagerService, RenderManagerService } from '@univerjs/engine-render';
import {
CopySheetCommand,
CopyWorksheetEndMutation,
@@ -101,6 +102,7 @@ export function createSheetsDrawingTestBed(workbookData?: IWorkbookData, depende
this._injector.get(IUndoRedoService);
([
[IRenderManagerService, { useClass: RenderManagerService }],
[SheetInterceptorService],
[SheetLazyExecuteScheduleService],
[IDrawingManagerService, { useClass: DrawingManagerService }],
@@ -88,7 +88,7 @@ export const InsertSheetDrawingCommand: ICommand = {
const result = sequenceExecute(redoMutations, commandService);
if (result) {
if (result.result) {
undoRedoService.pushUndoRedo({
unitID: unitId,
undoMutations,
@@ -94,7 +94,7 @@ export const RemoveSheetDrawingCommand: ICommand = {
const result = sequenceExecute(redoMutations, commandService);
if (result) {
if (result.result) {
undoRedoService.pushUndoRedo({
unitID: unitId,
undoMutations,
@@ -87,7 +87,7 @@ export const SetSheetDrawingCommand: ICommand<ISetDrawingCommandParams> = {
];
const result = sequenceExecute(redoMutations, commandService);
if (result) {
if (result.result) {
undoRedoService.pushUndoRedo({
unitID: unitId,
undoMutations,
@@ -20,7 +20,7 @@ import type { ICellDataWithSpanInfo } from '@univerjs/sheets-ui';
import { DisposableCollection, ICommandService, ILogService, Inject, Injector, IUniverInstanceService, LocaleService, LocaleType, LogLevel, ObjectMatrix, Plugin, RANGE_TYPE, UndoCommand, Univer, UniverInstanceType } from '@univerjs/core';
import { CalculateFormulaService, DefinedNamesService, FormulaCurrentConfigService, FormulaDataModel, FormulaRuntimeService, HyperlinkEngineFormulaService, ICalculateFormulaService, IDefinedNamesService, IFormulaCurrentConfigService, IFormulaRuntimeService, IHyperlinkEngineFormulaService, LexerTreeBuilder, SetArrayFormulaDataMutation, SetFormulaDataMutation } from '@univerjs/engine-formula';
import { IRenderManagerService, RenderManagerService } from '@univerjs/engine-render';
import { discreteRangeToRange, MoveRangeMutation, SetRangeValuesMutation, SetSelectionsOperation, SetWorksheetRowAutoHeightMutation, SheetInterceptorService, SheetSkeletonService, SheetsSelectionsService } from '@univerjs/sheets';
import { discreteRangeToRange, MoveRangeMutation, SetRangeValuesMutation, SetSelectionsOperation, SetWorksheetActiveOperation, SetWorksheetRowAutoHeightMutation, SheetInterceptorService, SheetSkeletonService, SheetsSelectionsService } from '@univerjs/sheets';
import { UpdateFormulaController } from '@univerjs/sheets-formula';
import { COPY_TYPE, IMarkSelectionService, ISheetClipboardService, ISheetSelectionRenderService, PREDEFINED_HOOK_NAME_PASTE, SheetClipboardController, SheetClipboardService, SheetSelectionRenderService, SheetSkeletonManagerService } from '@univerjs/sheets-ui';
import { BrowserClipboardService, DesktopMessageService, IClipboardInterfaceService, IMessageService, INotificationService, IPlatformService, IUIPartsService, UIPartsService } from '@univerjs/ui';
@@ -280,6 +280,7 @@ describe('Test cut command with formulas', () => {
commandService.registerCommand(SetWorksheetRowAutoHeightMutation);
commandService.registerCommand(SetFormulaDataMutation);
commandService.registerCommand(SetArrayFormulaDataMutation);
commandService.registerCommand(SetWorksheetActiveOperation);
sheetClipboardService = get(ISheetClipboardService);
get(UpdateFormulaController);
@@ -150,7 +150,7 @@ export const UpdateHyperLinkCommand: ICommand<IUpdateHyperLinkCommandParams> = {
}
const res = sequenceExecute(redos, commandService);
if (res) {
if (res.result) {
const isValid = await interceptorService.onValidateCell(workbook, worksheet, row, column);
if (isValid === false) {
sequenceExecute(undos, commandService);
@@ -79,14 +79,16 @@ export const AddSheetTableCommand: ICommand<IAddSheetTableCommandParams> = {
const res = sequenceExecute(redos, commandService);
if (res) {
if (res.result) {
undoRedoService.pushUndoRedo({
unitID: params.unitId,
undoMutations: undos,
redoMutations: redos,
});
return true;
}
return true;
return false;
},
};
@@ -89,15 +89,17 @@ export const AddTableThemeCommand: ICommand<IAddTableThemeCommandParams> = {
const commandService = accessor.get(ICommandService);
const res = sequenceExecute(redos, commandService);
if (res) {
if (res.result) {
const undoRedoService = accessor.get(IUndoRedoService);
undoRedoService.pushUndoRedo({
unitID: unitId,
undoMutations: undos,
redoMutations: redos,
});
return true;
}
return true;
return false;
},
};
@@ -60,14 +60,16 @@ export const DeleteSheetTableCommand: ICommand<IDeleteSheetTableParams> = {
const res = sequenceExecute(redos, commandService);
if (res) {
if (res.result) {
undoRedoService.pushUndoRedo({
unitID: params.unitId,
undoMutations: undos,
redoMutations: redos,
});
return true;
}
return true;
return false;
},
};
@@ -65,15 +65,17 @@ export const RemoveTableThemeCommand: ICommand<IRemoveTableThemeCommandParams> =
const commandService = accessor.get(ICommandService);
const res = sequenceExecute(redos, commandService);
if (res) {
if (res.result) {
const undoRedoService = accessor.get(IUndoRedoService);
undoRedoService.pushUndoRedo({
unitID: unitId,
redoMutations: redos,
undoMutations: undos,
});
return true;
}
return true;
return false;
},
};
@@ -38,14 +38,16 @@ export const SetSheetTableFilterCommand: ICommand<ISetSheetTableParams> = {
const res = sequenceExecute(redos, commandService);
if (res) {
if (res.result) {
undoRedoService.pushUndoRedo({
unitID: params.unitId,
undoMutations: undos,
redoMutations: redos,
});
return true;
}
return true;
return false;
},
};
@@ -180,16 +180,18 @@ export const SheetTableInsertRowCommand: ICommand<ISheetTableRowColOperationComm
const commandService = accessor.get(ICommandService);
const res = sequenceExecute(redos, commandService);
if (res) {
if (res.result) {
const undoRedoService = accessor.get(IUndoRedoService);
undoRedoService.pushUndoRedo({
unitID: unitId,
undoMutations: undos,
redoMutations: redos,
});
return true;
}
return true;
return false;
},
};
@@ -334,16 +336,18 @@ export const SheetTableInsertColCommand: ICommand<ISheetTableRowColOperationComm
}
const commandService = accessor.get(ICommandService);
const res = sequenceExecute(redos, commandService);
if (res) {
if (res.result) {
const undoRedoService = accessor.get(IUndoRedoService);
undoRedoService.pushUndoRedo({
unitID: unitId,
undoMutations: undos,
redoMutations: redos,
});
return true;
}
return true;
return false;
},
};
@@ -439,16 +443,18 @@ export const SheetTableRemoveRowCommand: ICommand<ISheetTableRowColOperationComm
const commandService = accessor.get(ICommandService);
const res = sequenceExecute(redos, commandService);
if (res) {
if (res.result) {
const undoRedoService = accessor.get(IUndoRedoService);
undoRedoService.pushUndoRedo({
unitID: unitId,
undoMutations: undos,
redoMutations: redos,
});
return true;
}
return true;
return false;
},
};
@@ -557,15 +563,17 @@ export const SheetTableRemoveColCommand: ICommand<ISheetTableRowColOperationComm
const commandService = accessor.get(ICommandService);
const res = sequenceExecute(redos, commandService);
if (res) {
if (res.result) {
const undoRedoService = accessor.get(IUndoRedoService);
undoRedoService.pushUndoRedo({
unitID: unitId,
undoMutations: undos,
redoMutations: redos,
});
return true;
}
return true;
return false;
},
};
@@ -524,8 +524,8 @@ export const SelectAllCommand: ICommand<ISelectAllCommandParams> = {
}
const commandService = accessor.get(ICommandService);
sequenceExecute(redos, commandService);
const result = sequenceExecute(redos, commandService);
return true;
return result.result;
},
};
@@ -24,6 +24,7 @@ import {
RemoveWorksheetMergeMutation,
SetRangeValuesMutation,
SetSelectionsOperation,
SetWorksheetActiveOperation,
SetWorksheetColWidthMutation,
SetWorksheetRowAutoHeightMutation,
SetWorksheetRowHeightMutation,
@@ -75,6 +76,7 @@ describe('Test clipboard', () => {
commandService.registerCommand(SetSelectionsOperation);
commandService.registerCommand(MoveRangeMutation);
commandService.registerCommand(SetWorksheetRowAutoHeightMutation);
commandService.registerCommand(SetWorksheetActiveOperation);
sheetClipboardService = get(ISheetClipboardService);
@@ -381,7 +381,7 @@ export class SheetClipboardService extends Disposable implements ISheetClipboard
const element = undoRedoService.pitchTopUndoElement();
if (element) {
const result = sequenceExecute(element.undoMutations, this._commandService);
if (result) {
if (result.result) {
undoRedoService.popUndoToRedo();
}
}
@@ -113,6 +113,7 @@ export function createCommandTestBed(workbookData?: IWorkbookData, dependencies?
dependencies?.forEach((d) => injector.add(d));
this._injector.get(SheetInterceptorService);
this._injector.get(SheetSkeletonService);
this._injector.get(WorkbookPermissionService);
this._injector.get(WorksheetPermissionService);
}
@@ -33,6 +33,7 @@ import {
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { SheetsSelectionsService } from '../../../services/selections/selection.service';
import { SetRangeValuesMutation } from '../../mutations/set-range-values.mutation';
import { SetSelectionsOperation } from '../../operations/selection.operation';
import { SetRangeValuesCommand } from '../set-range-values.command';
import { createCommandTestBed } from './create-command-test-bed';
@@ -153,6 +154,7 @@ describe('Test set range values commands', () => {
commandService = get(ICommandService);
commandService.registerCommand(SetRangeValuesCommand);
commandService.registerCommand(SetRangeValuesMutation);
commandService.registerCommand(SetSelectionsOperation);
selectionManager = get(SheetsSelectionsService);
selectionManager.addSelections([
@@ -213,7 +213,7 @@ export const AutoClearContentCommand: ICommand = {
];
const result = sequenceExecute(redos, commandService);
if (result) {
if (result.result) {
const afterInterceptors = sheetInterceptorService.afterCommandExecute({
id: SetRangeValuesMutation.id,
params: clearMutationParams,
@@ -20,7 +20,9 @@ import { CommandType, ICommandService, IUndoRedoService, IUniverInstanceService,
import { generateNullCell, getVisibleRanges } from '../../basics/utils';
import { SheetsSelectionsService } from '../../services/selections/selection.service';
import { SheetInterceptorService } from '../../services/sheet-interceptor/sheet-interceptor.service';
import { SheetSkeletonService } from '../../skeleton/skeleton.service';
import { SetRangeValuesMutation, SetRangeValuesUndoMutationFactory } from '../mutations/set-range-values.mutation';
import { getSuitableRangesInView } from './util';
import { getSheetCommandTarget } from './utils/target-util';
export interface IClearSelectionAllCommandParams {
@@ -41,19 +43,22 @@ export const ClearSelectionAllCommand: ICommand<IClearSelectionAllCommandParams>
const selectionManagerService = accessor.get(SheetsSelectionsService);
const { unitId, subUnitId } = target;
const selections = params?.ranges || selectionManagerService.getCurrentSelections()?.map((s) => s.range);
if (!selections?.length) return false;
const ranges = params?.ranges || selectionManagerService.getCurrentSelections()?.map((s) => s.range);
if (!ranges?.length) return false;
const sheetSkeletonService = accessor.get(SheetSkeletonService);
const skeleton = sheetSkeletonService.getSkeleton(unitId, subUnitId);
if (!skeleton) return false;
const commandService = accessor.get(ICommandService);
const undoRedoService = accessor.get(IUndoRedoService);
const sheetInterceptorService = accessor.get(SheetInterceptorService);
const visibleRanges = getVisibleRanges(selections, accessor, unitId, subUnitId);
const sequenceExecuteList: IMutationInfo[] = [];
const sequenceExecuteUndoList: IMutationInfo[] = [];
const redoMutations: IMutationInfo[] = [];
const undoMutations: IMutationInfo[] = [];
// clear style and content
const visibleRanges = getVisibleRanges(ranges, accessor, unitId, subUnitId);
const clearMutationParams: ISetRangeValuesMutationParams = {
subUnitId,
unitId,
@@ -64,28 +69,42 @@ export const ClearSelectionAllCommand: ICommand<IClearSelectionAllCommandParams>
clearMutationParams
);
sequenceExecuteList.push({
redoMutations.push({
id: SetRangeValuesMutation.id,
params: clearMutationParams,
});
sequenceExecuteUndoList.push({
undoMutations.push({
id: SetRangeValuesMutation.id,
params: undoClearMutationParams,
});
// intercept
const intercepted = sheetInterceptorService.onCommandExecute({ id: ClearSelectionAllCommand.id, params });
sequenceExecuteList.push(...intercepted.redos);
sequenceExecuteUndoList.unshift(...intercepted.undos);
const result = sequenceExecute(sequenceExecuteList, commandService);
redoMutations.push(...intercepted.redos);
undoMutations.unshift(...intercepted.undos);
const result = sequenceExecute(redoMutations, commandService);
// auto height
const { suitableRanges, remainingRanges } = getSuitableRangesInView(ranges, skeleton);
const { undos: autoHeightUndos, redos: autoHeightRedos } = sheetInterceptorService.generateMutationsOfAutoHeight({
unitId,
subUnitId,
ranges: suitableRanges,
autoHeightRanges: suitableRanges,
lazyAutoHeightRanges: remainingRanges,
});
const autoHeightExecuteResult = sequenceExecute(autoHeightRedos, commandService);
if (result.result && autoHeightExecuteResult.result) {
redoMutations.push(...autoHeightRedos);
undoMutations.push(...autoHeightUndos);
if (result) {
undoRedoService.pushUndoRedo({
// If there are multiple mutations that form an encapsulated project, they must be encapsulated in the same undo redo element.
// Hooks can be used to hook the code of external controllers to add new actions.
unitID: unitId,
undoMutations: sequenceExecuteUndoList,
redoMutations: sequenceExecuteList,
undoMutations,
redoMutations,
});
return true;
@@ -14,13 +14,15 @@
* limitations under the License.
*/
import type { ICommand, IRange } from '@univerjs/core';
import type { ICommand, IMutationInfo, IRange } from '@univerjs/core';
import type { ISetRangeValuesMutationParams } from '../mutations/set-range-values.mutation';
import { CommandType, ICommandService, IUndoRedoService, IUniverInstanceService, sequenceExecute } from '@univerjs/core';
import { generateNullCellValue, getVisibleRanges } from '../../basics/utils';
import { SheetsSelectionsService } from '../../services/selections/selection.service';
import { SheetInterceptorService } from '../../services/sheet-interceptor/sheet-interceptor.service';
import { SheetSkeletonService } from '../../skeleton/skeleton.service';
import { SetRangeValuesMutation, SetRangeValuesUndoMutationFactory } from '../mutations/set-range-values.mutation';
import { getSuitableRangesInView } from './util';
import { getSheetCommandTarget } from './utils/target-util';
export interface IClearSelectionContentCommandParams {
@@ -46,12 +48,19 @@ export const ClearSelectionContentCommand: ICommand<IClearSelectionContentComman
const ranges = params?.ranges || selectionManagerService.getCurrentSelections()?.map((s) => s.range);
if (!ranges?.length) return false;
const sheetSkeletonService = accessor.get(SheetSkeletonService);
const skeleton = sheetSkeletonService.getSkeleton(unitId, subUnitId);
if (!skeleton) return false;
const commandService = accessor.get(ICommandService);
const undoRedoService = accessor.get(IUndoRedoService);
const sheetInterceptorService = accessor.get(SheetInterceptorService);
const visibleRanges = getVisibleRanges(ranges, accessor, unitId, subUnitId);
const redoMutations: IMutationInfo[] = [];
const undoMutations: IMutationInfo[] = [];
// clear content
const visibleRanges = getVisibleRanges(ranges, accessor, unitId, subUnitId);
const clearMutationParams: ISetRangeValuesMutationParams = {
subUnitId,
unitId,
@@ -62,18 +71,42 @@ export const ClearSelectionContentCommand: ICommand<IClearSelectionContentComman
clearMutationParams
);
redoMutations.push({
id: SetRangeValuesMutation.id,
params: clearMutationParams,
});
undoMutations.push({
id: SetRangeValuesMutation.id,
params: undoClearMutationParams,
});
// intercept
const intercepted = sheetInterceptorService.onCommandExecute({ id: ClearSelectionContentCommand.id, params });
const redos = [{ id: SetRangeValuesMutation.id, params: clearMutationParams }, ...intercepted.redos];
const undos = [...intercepted.undos, { id: SetRangeValuesMutation.id, params: undoClearMutationParams }];
redoMutations.push(...intercepted.redos);
undoMutations.unshift(...intercepted.undos);
const result = sequenceExecute(redoMutations, commandService);
// auto height
const { suitableRanges, remainingRanges } = getSuitableRangesInView(ranges, skeleton);
const { undos: autoHeightUndos, redos: autoHeightRedos } = sheetInterceptorService.generateMutationsOfAutoHeight({
unitId,
subUnitId,
ranges: suitableRanges,
autoHeightRanges: suitableRanges,
lazyAutoHeightRanges: remainingRanges,
});
const autoHeightExecuteResult = sequenceExecute(autoHeightRedos, commandService);
if (result.result && autoHeightExecuteResult.result) {
redoMutations.push(...autoHeightRedos);
undoMutations.push(...autoHeightUndos);
const result = sequenceExecute(redos, commandService).result;
if (result) {
undoRedoService.pushUndoRedo({
// If there are multiple mutations that form an encapsulated project, they must be encapsulated in the same undo redo element.
// Hooks can be used to hook the code of external controllers to add new actions.
unitID: unitId,
undoMutations: undos,
redoMutations: redos,
undoMutations,
redoMutations,
});
return true;
@@ -20,7 +20,9 @@ import { CommandType, ICommandService, IUndoRedoService, IUniverInstanceService,
import { generateNullCellStyle, getVisibleRanges } from '../../basics/utils';
import { SheetsSelectionsService } from '../../services/selections/selection.service';
import { SheetInterceptorService } from '../../services/sheet-interceptor/sheet-interceptor.service';
import { SheetSkeletonService } from '../../skeleton/skeleton.service';
import { SetRangeValuesMutation, SetRangeValuesUndoMutationFactory } from '../mutations/set-range-values.mutation';
import { getSuitableRangesInView } from './util';
import { getSheetCommandTarget } from './utils/target-util';
export interface IClearSelectionFormatCommandParams {
@@ -46,16 +48,19 @@ export const ClearSelectionFormatCommand: ICommand<IClearSelectionFormatCommandP
const ranges = params?.ranges || selectionManagerService.getCurrentSelections()?.map((s) => s.range);
if (!ranges?.length) return false;
const sheetSkeletonService = accessor.get(SheetSkeletonService);
const skeleton = sheetSkeletonService.getSkeleton(unitId, subUnitId);
if (!skeleton) return false;
const commandService = accessor.get(ICommandService);
const undoRedoService = accessor.get(IUndoRedoService);
const sheetInterceptorService = accessor.get(SheetInterceptorService);
const visibleRanges = getVisibleRanges(ranges, accessor, unitId, subUnitId);
const sequenceExecuteList: IMutationInfo[] = [];
const sequenceExecuteUndoList: IMutationInfo[] = [];
const redoMutations: IMutationInfo[] = [];
const undoMutations: IMutationInfo[] = [];
// clear style
const visibleRanges = getVisibleRanges(ranges, accessor, unitId, subUnitId);
const clearMutationParams: ISetRangeValuesMutationParams = {
subUnitId,
unitId,
@@ -66,30 +71,42 @@ export const ClearSelectionFormatCommand: ICommand<IClearSelectionFormatCommandP
clearMutationParams
);
sequenceExecuteList.push({
redoMutations.push({
id: SetRangeValuesMutation.id,
params: clearMutationParams,
});
sequenceExecuteUndoList.push({
undoMutations.push({
id: SetRangeValuesMutation.id,
params: undoClearMutationParams,
});
// intercept
const intercepted = sheetInterceptorService.onCommandExecute({ id: ClearSelectionFormatCommand.id, params });
sequenceExecuteList.push(...intercepted.redos);
sequenceExecuteUndoList.unshift(...intercepted.undos);
redoMutations.push(...intercepted.redos);
undoMutations.unshift(...intercepted.undos);
const result = sequenceExecute(sequenceExecuteList, commandService);
const result = sequenceExecute(redoMutations, commandService);
// auto height
const { suitableRanges, remainingRanges } = getSuitableRangesInView(ranges, skeleton);
const { undos: autoHeightUndos, redos: autoHeightRedos } = sheetInterceptorService.generateMutationsOfAutoHeight({
unitId,
subUnitId,
ranges: suitableRanges,
autoHeightRanges: suitableRanges,
lazyAutoHeightRanges: remainingRanges,
});
const autoHeightExecuteResult = sequenceExecute(autoHeightRedos, commandService);
if (result.result && autoHeightExecuteResult.result) {
redoMutations.push(...autoHeightRedos);
undoMutations.push(...autoHeightUndos);
// const result = commandService.syncExecuteCommand(SetRangeValuesMutation.id, clearMutationParams);
if (result) {
undoRedoService.pushUndoRedo({
// If there are multiple mutations that form an encapsulated project, they must be encapsulated in the same undo redo element.
// Hooks can be used to hook the code of external controllers to add new actions.
unitID: unitId,
undoMutations: sequenceExecuteUndoList,
redoMutations: sequenceExecuteList,
undoMutations,
redoMutations,
});
return true;
@@ -162,7 +162,7 @@ export const InsertRangeMoveDownCommand: ICommand = {
// execute do mutations and add undo mutations to undo stack if completed
const result = sequenceExecute(redoMutations, commandService);
if (result) {
if (result.result) {
const afterInterceptors = sheetInterceptorService.afterCommandExecute({
id: InsertRangeMoveDownCommand.id,
params: { range } as IInsertRangeMoveDownCommandParams,
@@ -58,7 +58,7 @@ export const RemoveDefinedNameCommand: ICommand = {
const result = sequenceExecute(redos, commandService);
if (result) {
if (result.result) {
undoRedoService.pushUndoRedo({
unitID: params.unitId,
undoMutations: undos.filter(Boolean),
@@ -124,7 +124,7 @@ export const RemoveWorksheetMergeCommand: ICommand = {
const result = sequenceExecute(redoMutations, commandService);
if (result) {
if (result.result) {
undoRedoService.pushUndoRedo({
unitID: unitId,
undoMutations,
@@ -58,7 +58,7 @@ export const SetDefinedNameCommand: ICommand = {
const result = sequenceExecute(redos, commandService);
if (result) {
if (result.result) {
undoRedoService.pushUndoRedo({
unitID: params.unitId,
undoMutations: undos.filter(Boolean),
@@ -81,7 +81,7 @@ export const SetProtectionCommand: ICommand<ISetProtectionParams> = {
const result = sequenceExecute(redoMutations, commandService);
if (result) {
if (result.result) {
undoRedoService.pushUndoRedo({
unitID: unitId,
undoMutations,
@@ -30,7 +30,6 @@ import {
import { SheetsSelectionsService } from '../../services/selections/selection.service';
import { SheetInterceptorService } from '../../services/sheet-interceptor/sheet-interceptor.service';
import { SetRangeValuesMutation, SetRangeValuesUndoMutationFactory } from '../mutations/set-range-values.mutation';
import { SetSelectionsOperation } from '../operations/selection.operation';
import { followSelectionOperation } from './utils/selection-utils';
import { getSheetCommandTarget } from './utils/target-util';
@@ -133,15 +132,7 @@ export const SetRangeValuesCommand: ICommand = {
];
if (currentSelections && currentSelections.length) {
undoMutations.push({
id: SetSelectionsOperation.id,
params: {
unitId,
subUnitId,
selections: currentSelections,
reveal: true,
},
});
undoMutations.push(followSelectionOperation(currentSelections[currentSelections.length - 1], workbook, worksheet));
}
undoRedoService.pushUndoRedo({