From 6bd5f7ae01a7ac902b6abe94f961a2c25fc8cac2 Mon Sep 17 00:00:00 2001 From: dylan <> Date: Sat, 6 May 2023 15:24:29 -0700 Subject: [PATCH] Encountered undo error, but can't repro so adding logs --- codetab.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/codetab.ts b/codetab.ts index 01f8966..106e4c0 100644 --- a/codetab.ts +++ b/codetab.ts @@ -15,6 +15,7 @@ const state = { historyDebounce: 0, historyIndex: 0, undo() { + console.log('undoing'); if (this.historyIndex === this.history.length && this.historyDebounce > 0) { this.snapshot(); } @@ -26,6 +27,7 @@ const state = { } }, redo() { + console.log('redoing'); if (this.historyIndex < this.history.length-1) { this.historyIndex += 1; const snap = this.history[this.historyIndex]; @@ -34,13 +36,16 @@ const state = { } }, snapshot() { - this.history.push({ + const snap = { code: this.code, anchor: this.anchor, focus: this.focus, - }); + }; + this.history.push(snap); + console.log('took snapshot', this.historyIndex, snap); }, startSnapping() { + console.log('start snapping', this.historyIndex); this.historyIndex += 1; if (this.history.length > this.historyIndex) { this.history.length = this.historyIndex;