Update undo for grouping

This commit is contained in:
David Rowe 2017-10-06 10:42:23 +13:00
parent 21d286b422
commit 1673c08353
2 changed files with 8 additions and 10 deletions

View file

@ -143,10 +143,7 @@ Groups = function () {
selections.splice(1, selections.length - 1);
// Add history entry.
History.push(
{ setProperties: undoData },
{ setProperties: redoData }
);
History.push(null, { setProperties: undoData }, { setProperties: redoData });
}
function ungroup() {
@ -248,10 +245,7 @@ Groups = function () {
}
// Add history entry.
History.push(
{ setProperties: undoData },
{ setProperties: redoData }
);
History.push(null, { setProperties: undoData }, { setProperties: redoData });
}
function clear() {

View file

@ -47,8 +47,9 @@ History = (function () {
],
MAX_HISTORY_ITEMS = 1000,
undoPosition = -1, // The next history item to undo; the next history item to redo = undoIndex + 1.
undoData = [{}, {}],
redoData = [{}, {}];
undoData = [{}, {}, {}], // Left side, right side, no side.
redoData = [{}, {}, {}],
NO_SIDE = 2;
function doKick(entityID) {
var properties,
@ -81,6 +82,9 @@ History = (function () {
function push(side, undo, redo) {
// Add a history entry.
if (side === null) {
side = NO_SIDE;
}
undoData[side] = Object.merge(undoData[side], undo);
redoData[side] = Object.merge(redoData[side], redo);