diff --git a/model.js b/model.js index ed83f47b..ccf494f7 100644 --- a/model.js +++ b/model.js @@ -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(); }