Asset editor flushes pending writes

Avoid asset editor seeing stale data or
project file writes being lost when a delayed
editor read/write competes with a
synchronous asset editor read/write
This commit is contained in:
Fred Sauer committed 2026-03-25 22:23:29 -07:00
1 parent 6ce80f9154
commit ad5da2d810
4 files changed
+21 -1

No files matched your search

+3 -1
View File
@@ -477,7 +477,9 @@ export class AssetEditorView implements ProjectView, pixed.EditorContext {
setVisible?(showing: boolean): void {
// TODO: make into toolbar?
if (showing) {
// limit undo/redo to since opening this editor
// ensure asset editor is safe to perform synchronous reads/writes
projectWindows.flushAllWindows();
// limit undo/redo to since opening this asset editor
projectWindows.undofiles = [];
projectWindows.redofiles = [];
if (Mousetrap.bind) {
+1
View File
@@ -20,6 +20,7 @@ export interface ProjectView {
recreateOnResize?: boolean;
undoStep?(): void;
redoStep?(): void;
flushChanges?(): void;
replaceTextRange?(from: number, to: number, text: string): void;
};
+8
View File
@@ -282,6 +282,14 @@ export class SourceEditor implements ProjectView {
}, this.refreshDelayMsec);
}
flushChanges() {
if (this.updateTimer) {
clearTimeout(this.updateTimer);
this.updateTimer = null;
current_project.updateFile(this.path, this.editor.state.doc.toString());
}
}
inspectUnderCursor(update: ViewUpdate) {
// TODO: handle multi-select
const range = update.state.selection.main;
+9
View File
@@ -208,6 +208,15 @@ export class ProjectWindows {
bootbox.alert(msg, () => { this.alerting = false; });
}
flushAllWindows() {
for (var fileid in this.id2window) {
var wnd = this.id2window[fileid];
if (wnd && wnd.flushChanges) {
wnd.flushChanges();
}
}
}
updateAllOpenWindows(store) {
for (var fileid in this.id2window) {
var wnd = this.id2window[fileid];