Skip to content

Class

Manages undo/redo stacks for all spreadsheet operations.

oldData: Preserving Formula ASTs Across Irreversible Transformations

Section titled “oldData: Preserving Formula ASTs Across Irreversible Transformations”

Some structural operations (e.g., removing rows/columns, moving cells) destroy formula information that cannot be reconstructed from the transformation alone. For example, when a row is removed, formulas referencing that row are rewritten to #REF! — an irreversible change.

To support undo of such operations, oldData stores formula AST references keyed by the LazilyTransformingAstService version at which the irreversible transformation was applied. Each entry maps a version number to an array of [cellAddress, ast] pairs. These references keep the original formulas available independently of parser cache eviction, and are released when the snapshots expire.

Without cleanup, oldData grows indefinitely as undo entries are evicted but their oldData keys remain. Three mechanisms prevent this:

  1. Eviction cleanup: When undo entries are evicted (due to undoLimit), cleanupOldDataForEntries() deletes their referenced oldData keys (unless still needed by entries on the other stack).
  2. Orphan cleanup: Compaction may force lazy formula evaluation, which writes new oldData entries for already-evicted undo entries. After compaction, cleanupOrphanedOldData() removes any keys not referenced by entries on either stack or the in-progress batch.
  3. Short-circuit: When undoLimit is 0 (undo disabled), storeDataForVersion() returns immediately to avoid storing data that would never be used.

+ new UndoRedo(config: Config, operations: Operations): UndoRedo

Defined in hyperformula/src/UndoRedo.ts:514

Parameters:

Name Type
config Config
operations Operations

Returns: UndoRedo

• oldData: Map‹number, [SimpleCellAddress, Ast][]› = new Map()

Defined in hyperformula/src/UndoRedo.ts:510

▸ beginBatchMode(): void

Defined in hyperformula/src/UndoRedo.ts:531

Returns: void


▸ cleanupOrphanedOldData(): void

Defined in hyperformula/src/UndoRedo.ts:924

Removes oldData entries whose version keys are not referenced by any entry on the undo stack, redo stack, or in-progress batch. Called after compaction forces lazy formula evaluation, which may insert oldData for already-evicted entries.

Returns: void


▸ clearRedoStack(): void

Defined in hyperformula/src/UndoRedo.ts:559

Clears the redo stack and removes oldData entries no longer referenced by any remaining entry.

Returns: void


▸ clearUndoStack(): void

Defined in hyperformula/src/UndoRedo.ts:565

Clears the undo stack and removes oldData entries no longer referenced by any remaining entry.

Returns: void


▸ commitBatchMode(): void

Defined in hyperformula/src/UndoRedo.ts:535

Returns: void


▸ isRedoStackEmpty(): boolean

Defined in hyperformula/src/UndoRedo.ts:574

Returns: boolean


▸ isUndoStackEmpty(): boolean

Defined in hyperformula/src/UndoRedo.ts:570

Returns: boolean


▸ redo(): void

Defined in hyperformula/src/UndoRedo.ts:791

Returns: void


▸ redoAddColumns(operation: AddColumnsUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:852

Parameters:

Name Type
operation AddColumnsUndoEntry

Returns: void


▸ redoAddNamedExpression(operation: AddNamedExpressionUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:885

Parameters:

Name Type
operation AddNamedExpressionUndoEntry

Returns: void


▸ redoAddRows(operation: AddRowsUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:848

Parameters:

Name Type
operation AddRowsUndoEntry

Returns: void


▸ redoAddSheet(operation: AddSheetUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:860

Parameters:

Name Type
operation AddSheetUndoEntry

Returns: void


▸ redoBatch(batchOperation: BatchUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:803

Parameters:

Name Type
batchOperation BatchUndoEntry

Returns: void


▸ redoChangeNamedExpression(operation: ChangeNamedExpressionUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:893

Parameters:

Name Type
operation ChangeNamedExpressionUndoEntry

Returns: void


▸ redoClearSheet(operation: ClearSheetUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:876

Parameters:

Name Type
operation ClearSheetUndoEntry

Returns: void


▸ redoMoveCells(operation: MoveCellsUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:813

Parameters:

Name Type
operation MoveCellsUndoEntry

Returns: void


▸ redoMoveColumns(operation: MoveColumnsUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:872

Parameters:

Name Type
operation MoveColumnsUndoEntry

Returns: void


▸ redoMoveRows(operation: MoveRowsUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:868

Parameters:

Name Type
operation MoveRowsUndoEntry

Returns: void


▸ redoPaste(operation: PasteUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:826

Parameters:

Name Type
operation PasteUndoEntry

Returns: void


▸ redoRemoveColumns(operation: RemoveColumnsUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:817

Parameters:

Name Type
operation RemoveColumnsUndoEntry

Returns: void


▸ redoRemoveNamedExpression(operation: RemoveNamedExpressionUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:889

Parameters:

Name Type
operation RemoveNamedExpressionUndoEntry

Returns: void


▸ redoRemoveRows(operation: RemoveRowsUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:809

Parameters:

Name Type
operation RemoveRowsUndoEntry

Returns: void


▸ redoRemoveSheet(operation: RemoveSheetUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:856

Parameters:

Name Type
operation RemoveSheetUndoEntry

Returns: void


▸ redoRenameSheet(operation: RenameSheetUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:864

Parameters:

Name Type
operation RenameSheetUndoEntry

Returns: void


▸ redoSetCellContents(operation: SetCellContentsUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:840

Parameters:

Name Type
operation SetCellContentsUndoEntry

Returns: void


▸ redoSetColumnOrder(operation: SetColumnOrderUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:901

Parameters:

Name Type
operation SetColumnOrderUndoEntry

Returns: void


▸ redoSetRowOrder(operation: SetRowOrderUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:897

Parameters:

Name Type
operation SetRowOrderUndoEntry

Returns: void


▸ redoSetSheetContent(operation: SetSheetContentUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:880

Parameters:

Name Type
operation SetSheetContentUndoEntry

Returns: void


▸ saveOperation(operation: UndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:523

Parameters:

Name Type
operation UndoEntry

Returns: void


▸ storeDataForVersion(version: number, address: SimpleCellAddress, ast: Ast): void

Defined in hyperformula/src/UndoRedo.ts:547

Retains a formula AST for the given LazilyTransformingAstService version. Skipped when undoLimit is 0 (undo disabled) to avoid storing data that would never be used.

Parameters:

Name Type
version number
address SimpleCellAddress
ast Ast

Returns: void


▸ undo(): void

Defined in hyperformula/src/UndoRedo.ts:578

Returns: void


▸ undoAddColumns(operation: AddColumnsUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:638

Parameters:

Name Type
operation AddColumnsUndoEntry

Returns: void


▸ undoAddNamedExpression(operation: AddNamedExpressionUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:771

Parameters:

Name Type
operation AddNamedExpressionUndoEntry

Returns: void


▸ undoAddRows(operation: AddRowsUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:627

Parameters:

Name Type
operation AddRowsUndoEntry

Returns: void


▸ undoAddSheet(operation: AddSheetUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:713

Parameters:

Name Type
operation AddSheetUndoEntry

Returns: void


▸ undoBatch(batchOperation: BatchUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:589

Parameters:

Name Type
batchOperation BatchUndoEntry

Returns: void


▸ undoChangeNamedExpression(operation: ChangeNamedExpressionUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:779

Parameters:

Name Type
operation ChangeNamedExpressionUndoEntry

Returns: void


▸ undoClearSheet(operation: ClearSheetUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:746

Parameters:

Name Type
operation ClearSheetUndoEntry

Returns: void


▸ undoMoveCells(operation: MoveCellsUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:701

Parameters:

Name Type
operation MoveCellsUndoEntry

Returns: void


▸ undoMoveColumns(operation: MoveColumnsUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:694

Parameters:

Name Type
operation MoveColumnsUndoEntry

Returns: void


▸ undoMoveRows(operation: MoveRowsUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:687

Parameters:

Name Type
operation MoveRowsUndoEntry

Returns: void


▸ undoPaste(operation: PasteUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:678

Parameters:

Name Type
operation PasteUndoEntry

Returns: void


▸ undoRemoveColumns(operation: RemoveColumnsUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:611

Parameters:

Name Type
operation RemoveColumnsUndoEntry

Returns: void


▸ undoRemoveNamedExpression(operation: RemoveNamedExpressionUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:775

Parameters:

Name Type
operation RemoveNamedExpressionUndoEntry

Returns: void


▸ undoRemoveRows(operation: RemoveRowsUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:595

Parameters:

Name Type
operation RemoveRowsUndoEntry

Returns: void


▸ undoRemoveSheet(operation: RemoveSheetUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:718

Parameters:

Name Type
operation RemoveSheetUndoEntry

Returns: void


▸ undoRenameSheet(operation: RenameSheetUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:736

Parameters:

Name Type
operation RenameSheetUndoEntry

Returns: void


▸ undoSetCellContents(operation: SetCellContentsUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:660

Parameters:

Name Type
operation SetCellContentsUndoEntry

Returns: void


▸ undoSetColumnOrder(operation: SetColumnOrderUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:787

Parameters:

Name Type
operation SetColumnOrderUndoEntry

Returns: void


▸ undoSetRowOrder(operation: SetRowOrderUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:783

Parameters:

Name Type
operation SetRowOrderUndoEntry

Returns: void


▸ undoSetSheetContent(operation: SetSheetContentUndoEntry): void

Defined in hyperformula/src/UndoRedo.ts:758

Parameters:

Name Type
operation SetSheetContentUndoEntry

Returns: void