mirror of
https://github.com/Microsoft/vscode
synced 2024-10-12 22:37:41 +00:00
Be sure to execute grouped undo / redo elements in order (#101789)
This commit is contained in:
parent
92a0f560f4
commit
6891688dfc
|
@ -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);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue