{"record":{"id":"fbfb7aa1efbda611","repo":"ramensoftware/windhawk","slug":"failed-to-save-all-files","errorCode":null,"errorMessage":"Failed to save all files","messagePattern":"Failed to save all files","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/windhawk-vscode/src/extension.ts","lineNumber":1911,"sourceCode":"\t\t\t}\n\n\t\t\twebviewIPC.deleteEditedModReply(this._view?.webview, message.messageId, {\n\t\t\t\tsucceeded\n\t\t\t});\n\n\t\t\ttry {\n\t\t\t\tawait this._postEditedModDetails();\n\t\t\t} catch (e) {\n\t\t\t\treportException(e);\n\t\t\t}\n\t\t},\n\t\texitEditorMode: async message => {\n\t\t\tconst data: ExitEditorModeData = message.data;\n\n\t\t\tlet succeeded = false;\n\t\t\ttry {\n\t\t\t\tif (!await vscode.workspace.saveAll(true)) {\n\t\t\t\t\tthrow new Error('Failed to save all files');\n\t\t\t\t}\n\n\t\t\t\twindhawkLogOutput?.dispose();\n\n\t\t\t\tif (this._editedModId) {\n\t\t\t\t\tif (this._editedModWasModified && data.saveToDrafts) {\n\t\t\t\t\t\tthis._utils.editorWorkspace.saveModToDrafts(this._editedModId);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis._utils.editorWorkspace.deleteModFromDrafts(this._editedModId);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis._editedModId = undefined;\n\t\t\t\tthis._editedModWasModified = false;\n\t\t\t\tthis._editedModCompilationFailed = false;\n\t\t\t\tawait this._utils.editorWorkspace.exitEditorMode();\n\n\t\t\t\tsucceeded = true;","sourceCodeStart":1893,"sourceCodeEnd":1929,"githubUrl":"https://github.com/ramensoftware/windhawk/blob/61d99ed8e182e1af1b60109612b6763ad1b4b74e/src/windhawk-vscode/src/extension.ts#L1893-L1929","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// before requesting exit\nconst dirty = vscode.workspace.textDocuments.filter(d => d.isDirty);\nif (dirty.length > 0) {\n  // surface/inspect these documents first; ensure each is saveable\n  console.log('dirty docs:', dirty.map(d => d.uri.toString()));\n}","typeGuard":null,"tryCatchPattern":"try {\n  await api.postMessage({ command: 'exitEditorMode', data: { saveToDrafts } });\n} catch (e) {\n  if (e.message === 'Failed to save all files') {\n    showSaveProblems(); // list unsaved/unsaveable documents, let user fix, then retry\n  } else { throw e; }\n}","preventionTips":["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."],"tags":["vscode-extension","file-save","workspace","editor-mode"],"backgroundTag":"file-write-failed","analyzedSha":"61d99ed8e182e1af1b60109612b6763ad1b4b74e","analyzedAt":"2026-09-12T14:02:41.115Z","contentChangedAt":"2026-09-12T14:02:41.115Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}