Fix problems with historyBuffer

This commit is contained in:
Misode
2019-09-13 14:59:30 +02:00
parent 7f8d21cee8
commit 7d4fb250cd

View File

@@ -63,18 +63,16 @@ function redo() {
function invalidated() {
if (historyIndex === history.length - 1) {
historyIndex += 1;
history.push(JSON.stringify(table));
if (history.length > historyBuffer) {
history = history.slice(-historyBuffer);
}
historyIndex = history.length - 1;
} else {
historyIndex += 1;
history = history.slice(0, historyIndex);
history.push(JSON.stringify(table));
}
if (history.length > historyBuffer) {
console.log('remove history');
historyIndex -= 1;
history.splice(0, 1);
}
updateView();
}