diff --git a/src/vs/platform/files/common/files.ts b/src/vs/platform/files/common/files.ts index 86252c893899b015533f126cb6744f5fb29d398a..6360e6830a51bef1cb1133ce792d04f65e5f5408 100644 --- a/src/vs/platform/files/common/files.ts +++ b/src/vs/platform/files/common/files.ts @@ -804,7 +804,7 @@ export interface IFilesConfiguration { eol: string; enableTrash: boolean; hotExit: string; - preventSaveConflicts: boolean; + saveConflictResolution: 'askUser' | 'overwriteFileOnDisk'; }; } diff --git a/src/vs/workbench/contrib/files/browser/editors/textFileSaveErrorHandler.ts b/src/vs/workbench/contrib/files/browser/editors/textFileSaveErrorHandler.ts index 1347bd30a29c1926dfb014da08cfc0b497bd27d0..5c214b0641dfb4d4ebc28b4ebe25a0906ad9b664 100644 --- a/src/vs/workbench/contrib/files/browser/editors/textFileSaveErrorHandler.ts +++ b/src/vs/workbench/contrib/files/browser/editors/textFileSaveErrorHandler.ts @@ -332,7 +332,7 @@ class ConfigureSaveConflictAction extends Action { } run(): Promise { - this.preferencesService.openSettings(undefined, 'files.preventSaveConflicts'); + this.preferencesService.openSettings(undefined, 'files.saveConflictResolution'); return Promise.resolve(true); } diff --git a/src/vs/workbench/contrib/files/browser/files.contribution.ts b/src/vs/workbench/contrib/files/browser/files.contribution.ts index f2f944b9836f962b9324906d27fcd3300d089529..691c176d94ad78270b1deca89c7c129ffcfa734e 100644 --- a/src/vs/workbench/contrib/files/browser/files.contribution.ts +++ b/src/vs/workbench/contrib/files/browser/files.contribution.ts @@ -322,10 +322,18 @@ configurationRegistry.registerConfiguration({ 'markdownDescription': nls.localize('maxMemoryForLargeFilesMB', "Controls the memory available to VS Code after restart when trying to open large files. Same effect as specifying `--max-memory=NEWSIZE` on the command line."), included: platform.isNative }, - 'files.preventSaveConflicts': { - 'type': 'boolean', - 'description': nls.localize('files.preventSaveConflicts', "When enabled, will prevent to save a file that has been changed since it was last edited. Instead, a diff editor is provided to compare the changes and accept or revert them. This setting should only be disabled if you frequently encounter save conflict errors and may result in data loss if used without caution."), - 'default': true, + 'files.saveConflictResolution': { + 'type': 'string', + 'enum': [ + 'askUser', + 'overwriteFileOnDisk' + ], + 'enumDescriptions': [ + nls.localize('askUser', "Will refuse to save and ask for resolving the save conflict manually."), + nls.localize('overwriteFileOnDisk', "Will resolve the save conflict by overwriting the file on disk with the changes in the editor.") + ], + 'description': nls.localize('files.saveConflictResolution', "A save conflict can occur when a file is saved to disk that was changed by another program in the meantime. To prevent data loss, the user is asked to compare the changes in the editor with the version on disk. This setting should only be changed if you frequently encounter save conflict errors and may result in data loss if used without caution."), + 'default': 'askUser', 'scope': ConfigurationScope.LANGUAGE_OVERRIDABLE }, 'files.simpleDialog.enable': { diff --git a/src/vs/workbench/services/filesConfiguration/common/filesConfigurationService.ts b/src/vs/workbench/services/filesConfiguration/common/filesConfigurationService.ts index 0df4d59fa9b70938dcbdd0df9d2d4ed088678660..7a9048cba8de147b98366f5bc7eb91f5446fffc2 100644 --- a/src/vs/workbench/services/filesConfiguration/common/filesConfigurationService.ts +++ b/src/vs/workbench/services/filesConfiguration/common/filesConfigurationService.ts @@ -211,7 +211,7 @@ export class FilesConfigurationService extends Disposable implements IFilesConfi } preventSaveConflicts(resource: URI, language: string): boolean { - return this.configurationService.getValue('files.preventSaveConflicts', { resource, overrideIdentifier: language }); + return this.configurationService.getValue('files.saveConflictResolution', { resource, overrideIdentifier: language }) !== 'overwriteFileOnDisk'; } }