diff --git a/ArduinoFrontend/src/app/Libs/UndoUtils.ts b/ArduinoFrontend/src/app/Libs/UndoUtils.ts index 550af18f..0425e1de 100644 --- a/ArduinoFrontend/src/app/Libs/UndoUtils.ts +++ b/ArduinoFrontend/src/app/Libs/UndoUtils.ts @@ -50,7 +50,14 @@ export abstract class UndoUtils { this.loadChange(cng, 'redo'); } } - + /** + * Resets the undo and redo stacks + */ + static resetStacks() { + UndoUtils.undo = []; // Clear undo stack + UndoUtils.redo = []; // Clear redo stack + console.log('Undo and redo stacks have been reset.'); + } /** * Function to reset redo stack & push into undo stack * @param ele event snapshot diff --git a/ArduinoFrontend/src/app/Libs/Workspace.ts b/ArduinoFrontend/src/app/Libs/Workspace.ts index f60ffadc..34870b34 100644 --- a/ArduinoFrontend/src/app/Libs/Workspace.ts +++ b/ArduinoFrontend/src/app/Libs/Workspace.ts @@ -687,8 +687,7 @@ export class Workspace { ${Workspace.scale}) translate(${Workspace.translateX}, ${Workspace.translateY})`); - - // For each component key in the data + // For each component key in the data for (const key in data) { // Check if key is valid if (!(key in data)) { @@ -720,7 +719,6 @@ export class Workspace { obj.load(comp); } } - } } // Wait until all components are drawn @@ -733,7 +731,7 @@ export class Workspace { window.hideLoading(); } }, 100); - + UndoUtils.resetStacks(); } /** This function recreates the wire object */ static LoadWires(wires: any[], retainId = false, pushUndo = false) { @@ -792,6 +790,7 @@ export class Workspace { } Workspace.circuitLoaded = true; Workspace.circuitLoadStatus.emit(true); + UndoUtils.resetStacks(); } /** Function to delete component fro Workspace */