未验证 提交 6891688d 编写于 作者: A Alex Dima

Be sure to execute grouped undo / redo elements in order (#101789)

上级 92a0f560
......@@ -985,9 +985,9 @@ export class UndoRedoService implements IUndoRedoService {
});
}
private _continueUndoInGroup(groupId: number): Promise<void> | void {
private _findClosestUndoElementInGroup(groupId: number): [StackElement | null, string | null] {
if (!groupId) {
return;
return [null, null];
}
// find another element with the same groupId and with the highest groupOrder ready to be undone
......@@ -1007,6 +1007,15 @@ export class UndoRedoService implements IUndoRedoService {
}
}
return [matchedElement, matchedStrResource];
}
private _continueUndoInGroup(groupId: number): Promise<void> | void {
if (!groupId) {
return;
}
const [, matchedStrResource] = this._findClosestUndoElementInGroup(groupId);
if (matchedStrResource) {
return this.undo(matchedStrResource);
}
......@@ -1024,6 +1033,15 @@ export class UndoRedoService implements IUndoRedoService {
return;
}
if (element.groupId) {
// this element is a part of a group, we need to make sure undoing in a group is in order
const [matchedElement, matchedStrResource] = this._findClosestUndoElementInGroup(element.groupId);
if (element !== matchedElement && matchedStrResource) {
// there is an element in the same group that should be undone before this one
return this.undo(matchedStrResource);
}
}
try {
if (element.type === UndoRedoElementType.Workspace) {
return this._workspaceUndo(strResource, element);
......@@ -1190,9 +1208,9 @@ export class UndoRedoService implements IUndoRedoService {
});
}
private _continueRedoInGroup(groupId: number): Promise<void> | void {
private _findClosestRedoElementInGroup(groupId: number): [StackElement | null, string | null] {
if (!groupId) {
return;
return [null, null];
}
// find another element with the same groupId and with the lowest groupOrder ready to be redone
......@@ -1212,6 +1230,15 @@ export class UndoRedoService implements IUndoRedoService {
}
}
return [matchedElement, matchedStrResource];
}
private _continueRedoInGroup(groupId: number): Promise<void> | void {
if (!groupId) {
return;
}
const [, matchedStrResource] = this._findClosestRedoElementInGroup(groupId);
if (matchedStrResource) {
return this.redo(matchedStrResource);
}
......@@ -1229,6 +1256,15 @@ export class UndoRedoService implements IUndoRedoService {
return;
}
if (element.groupId) {
// this element is a part of a group, we need to make sure redoing in a group is in order
const [matchedElement, matchedStrResource] = this._findClosestRedoElementInGroup(element.groupId);
if (element !== matchedElement && matchedStrResource) {
// there is an element in the same group that should be redone before this one
return this.redo(matchedStrResource);
}
}
try {
if (element.type === UndoRedoElementType.Workspace) {
return this._workspaceRedo(strResource, element);
......
......@@ -210,7 +210,9 @@ suite('UndoRedoService', () => {
});
test('UndoRedoGroup.None uses id 0', () => {
assert.equal(UndoRedoGroup.None, 0);
assert.equal(UndoRedoGroup.None.id, 0);
assert.equal(UndoRedoGroup.None.nextOrder(), 0);
assert.equal(UndoRedoGroup.None.nextOrder(), 0);
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册