Fix findUsages/undo/node-lookup bugs, split Viewport and Editor, share command and inspector helpers
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1eb28314cf
commit
f140c2fd77
58 files changed
+1969
-1171
No files matched your search
+23
-12
@@ -136,8 +136,28 @@ export class EditorState {
|
||||
* In play mode the command changes the runtime copy only (see `enterPlay`).
|
||||
*/
|
||||
execute(command: Command): boolean {
|
||||
try {
|
||||
return this.runEdit(() => {
|
||||
this.commands.execute(command);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
undo(): void {
|
||||
this.runEdit(() => this.commands.undo());
|
||||
}
|
||||
|
||||
redo(): void {
|
||||
this.runEdit(() => this.commands.redo());
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs one history operation. A `CommandError` is the documented way for a command to
|
||||
* reject an edit, so it becomes a notice; anything else is a real defect and keeps
|
||||
* travelling. Undo and redo go through here too – they can reject just like `execute`.
|
||||
*/
|
||||
private runEdit(operation: () => boolean): boolean {
|
||||
try {
|
||||
if (!operation()) return false;
|
||||
} catch (error) {
|
||||
if (error instanceof CommandError) {
|
||||
this.setNotice(error.message);
|
||||
@@ -149,16 +169,6 @@ export class EditorState {
|
||||
return true;
|
||||
}
|
||||
|
||||
undo(): void {
|
||||
if (!this.commands.undo()) return;
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
redo(): void {
|
||||
if (!this.commands.redo()) return;
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
/**
|
||||
* The model was mutated directly (live preview while scrubbing). Notifies listeners
|
||||
* but does not touch the undo stack or the save status – the committing command does.
|
||||
@@ -246,7 +256,8 @@ export class EditorState {
|
||||
}
|
||||
}
|
||||
|
||||
function sameSelection(a: Selection, b: Selection): boolean {
|
||||
/** Whether two selections mean the same thing (same kind, same ids, same order). */
|
||||
export function sameSelection(a: Selection, b: Selection): boolean {
|
||||
if (a === b) return true;
|
||||
if (!a || !b || a.kind !== b.kind) return false;
|
||||
if (a.kind === 'asset' && b.kind === 'asset') return a.assetId === b.assetId;
|
||||
|
||||
Reference in new issue
Block a user