fix: no group

This commit is contained in:
cha0s 2022-04-15 12:35:21 -05:00
parent e698a92b17
commit 3b8658144e
2 changed files with 10 additions and 3 deletions

View File

@ -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));
}

View File

@ -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});