diff --git a/demo/src/setup.common.ts b/demo/src/setup.common.ts index 0a052490..a6762288 100644 --- a/demo/src/setup.common.ts +++ b/demo/src/setup.common.ts @@ -288,7 +288,7 @@ export const constructOptions: IWorkbenchConstructionOptions = { export const envOptions: EnvironmentOverride = { // Otherwise, VSCode detect it as the first open workspace folder // which make the search result extension fail as it's not able to know what was detected by VSCode - userHome: vscode.Uri.file('/') + // userHome: vscode.Uri.file('/') } export const commonServices: IEditorOverrideServices = { diff --git a/src/service-override/workingCopy.ts b/src/service-override/workingCopy.ts index b63e10f2..aca97e51 100644 --- a/src/service-override/workingCopy.ts +++ b/src/service-override/workingCopy.ts @@ -1,6 +1,5 @@ import { IEditorOverrideServices } from 'vs/editor/standalone/browser/standaloneServices' import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors' -import { BrowserWorkingCopyBackupService } from 'vs/workbench/services/workingCopy/browser/workingCopyBackupService' import { IWorkingCopyBackupService } from 'vs/workbench/services/workingCopy/common/workingCopyBackup.service' import { WorkingCopyService } from 'vs/workbench/services/workingCopy/common/workingCopyService' import { IWorkingCopyService } from 'vs/workbench/services/workingCopy/common/workingCopyService.service' @@ -8,12 +7,42 @@ import { WorkingCopyEditorService } from 'vs/workbench/services/workingCopy/comm import { IWorkingCopyEditorService } from 'vs/workbench/services/workingCopy/common/workingCopyEditorService.service' import { IWorkingCopyHistoryService } from 'vs/workbench/services/workingCopy/common/workingCopyHistory.service' import { BrowserWorkingCopyHistoryService } from 'vs/workbench/services/workingCopy/browser/workingCopyHistoryService' +import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace.service' +import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService.service' +import { IFileService } from 'vs/platform/files/common/files.service' +import { ILogService } from 'vs/platform/log/common/log.service' +import { joinPath } from 'vs/base/common/resources' +import { WorkingCopyBackupService } from 'vs/workbench/services/workingCopy/common/workingCopyBackupService' import getFileServiceOverride from './files' -export default function getServiceOverride (): IEditorOverrideServices { +class BrowserWorkingCopyBackupService extends WorkingCopyBackupService { + constructor ( + memory: boolean, + @IWorkspaceContextService contextService: IWorkspaceContextService, + @IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService, + @IFileService fileService: IFileService, + @ILogService logService: ILogService + ) { + super( + memory ? undefined : joinPath(environmentService.userRoamingDataHome, 'Backups', contextService.getWorkspace().id), + fileService, + logService + ) + } +} + +interface WorkingCopyServiceOptions { + storage: 'memory' | 'userData' | null +} + +export default function getServiceOverride ({ storage }: WorkingCopyServiceOptions): IEditorOverrideServices { return { ...getFileServiceOverride(), - [IWorkingCopyBackupService.toString()]: new SyncDescriptor(BrowserWorkingCopyBackupService, [], false), + ...(storage != null + ? { + [IWorkingCopyBackupService.toString()]: new SyncDescriptor(BrowserWorkingCopyBackupService, [storage === 'memory'], false) + } + : {}), [IWorkingCopyService.toString()]: new SyncDescriptor(WorkingCopyService, [], false), [IWorkingCopyEditorService.toString()]: new SyncDescriptor(WorkingCopyEditorService, [], false), [IWorkingCopyHistoryService.toString()]: new SyncDescriptor(BrowserWorkingCopyHistoryService, [], false)