ramensoftware/windhawk · error
Failed to save all files
Error message
Failed to save all files
What it means
exitEditorMode requires that all dirty editors in the workspace be persisted before leaving edit mode, because the mod source is then read from disk (and optionally saved to drafts or the installed mod). vscode.workspace.saveAll(true) returning false means at least one file could not be saved, so the handler aborts the exit.
Solutions
- Check the VS Code Problems/notifications for which document failed to save and resolve it (restore the file, fix permissions, save manually).
- Close editors whose backing files no longer exist, then retry exiting editor mode.
- Save all files manually (Ctrl+K S) and confirm no dirty editors remain before retrying.
- Retry after releasing external locks (antivirus scan, other editors) on the mod directory.
Defensive patterns
Strategy: validation
Validate before calling
// before requesting exit
const dirty = vscode.workspace.textDocuments.filter(d => d.isDirty);
if (dirty.length > 0) {
// surface/inspect these documents first; ensure each is saveable
console.log('dirty docs:', dirty.map(d => d.uri.toString()));
} Try / catch
try {
await api.postMessage({ command: 'exitEditorMode', data: { saveToDrafts } });
} catch (e) {
if (e.message === 'Failed to save all files') {
showSaveProblems(); // list unsaved/unsaveable documents, let user fix, then retry
} else { throw e; }
} Prevention
- Close or save scratch/untitled editors before exiting editor mode.
- Keep mod files under source control and avoid deleting/moving them while open in VS Code.
- Watch for file locks from antivirus or sync tools on the mods directory.
- Run a manual save-all and confirm zero dirty editors before triggering exit.
When it happens
Trigger: Calling exitEditorMode (with or without saveToDrafts) while any dirty document fails to save — e.g. a file locked by another process, a deleted-on-disk buffer, an untitled document that cannot be written, or a permission problem.
Common situations: A mod file was deleted or moved on disk while open; another program holds a lock on the file (Windows AV scanners, editors); the workspace folder became read-only; an untitled scratch buffer counts as dirty and cannot be saved silently.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
AI-assisted analysis of ramensoftware/windhawk@61d99ed8e1 (2026-09-12).
Data as JSON: /api/errors/fbfb7aa1efbda611.
Report an issue: GitHub.
Appendix: source
Thrown at src/windhawk-vscode/src/extension.ts:1911
}
webviewIPC.deleteEditedModReply(this._view?.webview, message.messageId, {
succeeded
});
try {
await this._postEditedModDetails();
} catch (e) {
reportException(e);
}
},
exitEditorMode: async message => {
const data: ExitEditorModeData = message.data;
let succeeded = false;
try {
if (!await vscode.workspace.saveAll(true)) {
throw new Error('Failed to save all files');
}
windhawkLogOutput?.dispose();
if (this._editedModId) {
if (this._editedModWasModified && data.saveToDrafts) {
this._utils.editorWorkspace.saveModToDrafts(this._editedModId);
} else {
this._utils.editorWorkspace.deleteModFromDrafts(this._editedModId);
}
}
this._editedModId = undefined;
this._editedModWasModified = false;
this._editedModCompilationFailed = false;
await this._utils.editorWorkspace.exitEditorMode();
succeeded = true;View on GitHub (pinned to 61d99ed8e1)