diff --git a/packages/core/src/server/packets/decorators/action.js b/packages/core/src/server/packets/decorators/action.js index 4acc446..2e2a0d3 100644 --- a/packages/core/src/server/packets/decorators/action.js +++ b/packages/core/src/server/packets/decorators/action.js @@ -29,7 +29,10 @@ export default (Action, flecks) => class ProjectAction extends Action { const {group, patch} = json.history.redo.at(-1); socket.send(['Action', patchJsonResource({patch, project, uri}, true)]); applyPatch(json, patch); - json.history.undo.push({group, patch: compare(json, fromBuffer(buffer, flecks))}); + json.history.undo.push({ + ...(group && {group}), + patch: compare(json, fromBuffer(buffer, flecks)), + }); json.history.redo.pop(); await writeFile(path, toBuffer(json, flecks)); } @@ -50,7 +53,10 @@ export default (Action, flecks) => class ProjectAction extends Action { const {group, patch} = json.history.undo.at(-1); socket.send(['Action', patchJsonResource({patch, project, uri}, true)]); applyPatch(json, patch); - json.history.redo.push({group, patch: compare(json, fromBuffer(buffer, flecks))}); + json.history.redo.push({ + ...(group && {group}), + patch: compare(json, fromBuffer(buffer, flecks)), + }); json.history.undo.pop(); await writeFile(path, toBuffer(json, flecks)); } diff --git a/packages/core/src/server/start-flush.js b/packages/core/src/server/start-flush.js index 260e125..9fb212e 100644 --- a/packages/core/src/server/start-flush.js +++ b/packages/core/src/server/start-flush.js @@ -29,7 +29,8 @@ const startFlush = (flecks) => { json.history = json.history || {redo: [], undo: []}; json.history.redo = []; if ( - 0 === json.history.undo.length + !group + || 0 === json.history.undo.length || group !== json.history.undo.at(-1).group ) { json.history.undo.push({group, patch: undo});