Skip to content

Commit 2f9b82c

Browse files
Resets history on reload
1 parent f4bd012 commit 2f9b82c

File tree

1 file changed

+13
-3
lines changed
  • src/webviews/apps/plus/composer/components

1 file changed

+13
-3
lines changed

src/webviews/apps/plus/composer/components/app.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,7 @@ export class ComposerApp extends LitElement {
396396
private lastMouseEvent?: MouseEvent;
397397

398398
override firstUpdated() {
399-
// Initialize reset state
400-
this.initializeResetState();
399+
this.initializeResetStateIfNeeded();
401400
// Delay initialization to ensure DOM is ready
402401
setTimeout(() => this.initializeSortable(), 200);
403402
this.initializeDragTracking();
@@ -412,6 +411,8 @@ export class ComposerApp extends LitElement {
412411
override updated(changedProperties: Map<string | number | symbol, unknown>) {
413412
super.updated(changedProperties);
414413

414+
this.initializeResetStateIfNeeded();
415+
415416
// Reinitialize drop zones when commits change
416417
if (changedProperties.has('commits')) {
417418
setTimeout(() => this.initializeCommitDropZones(), 100);
@@ -632,12 +633,20 @@ export class ComposerApp extends LitElement {
632633
this.history.undoStack.push(this.createDataSnapshot());
633634
}
634635

635-
private initializeResetState() {
636+
private initializeResetStateIfNeeded() {
636637
if (!this.history.resetState) {
637638
this.history.resetState = this.createDataSnapshot();
638639
}
639640
}
640641

642+
private resetHistory() {
643+
this.history = {
644+
resetState: null,
645+
undoStack: [],
646+
redoStack: [],
647+
};
648+
}
649+
641650
private canUndo(): boolean {
642651
return this.history.undoStack.length > 0;
643652
}
@@ -1238,6 +1247,7 @@ export class ComposerApp extends LitElement {
12381247
}
12391248

12401249
private handleReloadComposer() {
1250+
this.resetHistory();
12411251
this._ipc.sendCommand(ReloadComposerCommand, {
12421252
repoPath: this.state.safetyState.repoPath,
12431253
mode: this.state.mode,

0 commit comments

Comments
 (0)