Skip to content

Commit a9c4743

Browse files
authored
fix(snapshot): changeset apply (#6623)
1 parent cd61b7f commit a9c4743

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

packages/core/src/services/command/command.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export interface IExecutionOptions {
190190
onlyLocal?: boolean;
191191
/** This command is from collaboration peers. */
192192
fromCollab?: boolean;
193-
/** @deprecated */
193+
/** This command is from snapshot load. */
194194
fromChangeset?: boolean;
195195
/**
196196
* This mutation should be synced to changeset but not executed locally.

packages/sheets-ui/src/controllers/render-controllers/sheet.render-controller.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import type { ICommandInfo, IRange, Nullable, Workbook, Worksheet } from '@univerjs/core';
17+
import type { ICommandInfo, IExecutionOptions, IRange, Nullable, Workbook, Worksheet } from '@univerjs/core';
1818
import type { ISetFormulaCalculationNotificationMutation } from '@univerjs/engine-formula';
1919
import type { IAfterRender$Info, IBasicFrameInfo, IExtendFrameInfo, IRenderContext, IRenderModule, IScrollBarProps, ISummaryFrameInfo, ISummaryMetric, ITimeMetric, IViewportInfos, Scene } from '@univerjs/engine-render';
2020
import type { IUniverSheetsUIConfig } from '../config.schema';
@@ -403,7 +403,7 @@ export class SheetRenderController extends RxDisposable implements IRenderModule
403403
}
404404

405405
private _initCommandListener(): void {
406-
this.disposeWithMe(this._commandService.onCommandExecuted((command: ICommandInfo) => {
406+
this.disposeWithMe(this._commandService.onCommandExecuted((command: ICommandInfo, options) => {
407407
const { unit: workbook } = this._context;
408408
const { id: commandId } = command;
409409

@@ -443,12 +443,12 @@ export class SheetRenderController extends RxDisposable implements IRenderModule
443443

444444
// All mutations must be executed. Using reCalculate alone will not trigger a refresh.
445445
if (command.type === CommandType.MUTATION) {
446-
this._markUnitDirty(command);
446+
this._markUnitDirty(command, options);
447447
}
448448
}));
449449
}
450450

451-
private _markUnitDirty(command: ICommandInfo) {
451+
private _markUnitDirty(command: ICommandInfo, options: IExecutionOptions | undefined) {
452452
if (command.id.substring(0, 3) === 'doc') {
453453
return;
454454
}
@@ -471,20 +471,20 @@ export class SheetRenderController extends RxDisposable implements IRenderModule
471471

472472
const cmdParams = command.params as Record<string, any>;
473473
const viewports = this._spreadsheetViewports(scene);
474-
if (command.id === SetRangeValuesMutation.id && cmdParams.cellValue) {
474+
if (command.id === SetRangeValuesMutation.id && cmdParams.cellValue && !options?.fromChangeset) {
475475
const dirtyRange: IRange = this._cellValueToRange(cmdParams.cellValue);
476476
const dirtyBounds = this._rangeToBounds([dirtyRange]);
477477
this._markViewportDirty(viewports, dirtyBounds);
478-
(spreadsheet as unknown as Spreadsheet).setDirtyArea(dirtyBounds);
478+
(spreadsheet as Spreadsheet).setDirtyArea(dirtyBounds);
479479
}
480480

481-
if (command.id === MoveRangeMutation.id && cmdParams.from && cmdParams.to) {
481+
if (command.id === MoveRangeMutation.id && cmdParams.from && cmdParams.to && !options?.fromChangeset) {
482482
// keep the get _cellValueToRange code to ensure the code can effect as before
483483
const fromRange = cmdParams.fromRange || this._cellValueToRange(cmdParams.from.value);
484484
const toRange = cmdParams.toRange || this._cellValueToRange(cmdParams.to.value);
485485
const dirtyBounds = this._rangeToBounds([fromRange, toRange]);
486486
this._markViewportDirty(viewports, dirtyBounds);
487-
(spreadsheet as unknown as Spreadsheet).setDirtyArea(dirtyBounds);
487+
(spreadsheet as Spreadsheet).setDirtyArea(dirtyBounds);
488488
}
489489
}
490490

0 commit comments

Comments
 (0)