fix: preserve area relocation state

Issue: #403
User-Visible: yes
This commit is contained in:
Sergey Matyunin
2026-09-01 15:08:22 +00:00
committed by claude[bot]
parent 09613ce322
commit 355b0516c7
28 changed files with 550 additions and 190 deletions
+9
View File
@@ -48,6 +48,15 @@ export class CommandStack<T> {
return command;
}
/** Remove commands invalidated by an external change while preserving unrelated history. */
public removeWhere(predicate: (command: NamedCommand<T>) => boolean): number {
const undoSize = this._undo.length;
const redoSize = this._redo.length;
this._undo = this._undo.filter((command) => !predicate(command));
this._redo = this._redo.filter((command) => !predicate(command));
return undoSize + redoSize - this._undo.length - this._redo.length;
}
public clear(): void {
this._undo = [];
this._redo = [];