Encountered undo error, but can't repro so adding logs
This commit is contained in:
parent
3518538b39
commit
6bd5f7ae01
@ -15,6 +15,7 @@ const state = {
|
|||||||
historyDebounce: 0,
|
historyDebounce: 0,
|
||||||
historyIndex: 0,
|
historyIndex: 0,
|
||||||
undo() {
|
undo() {
|
||||||
|
console.log('undoing');
|
||||||
if (this.historyIndex === this.history.length && this.historyDebounce > 0) {
|
if (this.historyIndex === this.history.length && this.historyDebounce > 0) {
|
||||||
this.snapshot();
|
this.snapshot();
|
||||||
}
|
}
|
||||||
@ -26,6 +27,7 @@ const state = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
redo() {
|
redo() {
|
||||||
|
console.log('redoing');
|
||||||
if (this.historyIndex < this.history.length-1) {
|
if (this.historyIndex < this.history.length-1) {
|
||||||
this.historyIndex += 1;
|
this.historyIndex += 1;
|
||||||
const snap = this.history[this.historyIndex];
|
const snap = this.history[this.historyIndex];
|
||||||
@ -34,13 +36,16 @@ const state = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
snapshot() {
|
snapshot() {
|
||||||
this.history.push({
|
const snap = {
|
||||||
code: this.code,
|
code: this.code,
|
||||||
anchor: this.anchor,
|
anchor: this.anchor,
|
||||||
focus: this.focus,
|
focus: this.focus,
|
||||||
});
|
};
|
||||||
|
this.history.push(snap);
|
||||||
|
console.log('took snapshot', this.historyIndex, snap);
|
||||||
},
|
},
|
||||||
startSnapping() {
|
startSnapping() {
|
||||||
|
console.log('start snapping', this.historyIndex);
|
||||||
this.historyIndex += 1;
|
this.historyIndex += 1;
|
||||||
if (this.history.length > this.historyIndex) {
|
if (this.history.length > this.historyIndex) {
|
||||||
this.history.length = this.historyIndex;
|
this.history.length = this.historyIndex;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user