diff --git a/src/vs/platform/backup/common/backup.ts b/src/vs/platform/backup/common/backup.ts index 35da1b989f0..3a01510ed61 100644 --- a/src/vs/platform/backup/common/backup.ts +++ b/src/vs/platform/backup/common/backup.ts @@ -40,7 +40,7 @@ export interface IBackupMainService { * Gets the set of untitled file backups for a particular workspace. * * @param workspace The workspace to get the backups for. - * @return The absolute paths for all the untitled file _backups_. + * @return The base names for the untitled file _backups_. */ getWorkspaceUntitledFileBackupsSync(workspace: Uri): string[]; diff --git a/src/vs/platform/backup/node/backupMainService.ts b/src/vs/platform/backup/node/backupMainService.ts index b7edd360807..6f1a34c410e 100644 --- a/src/vs/platform/backup/node/backupMainService.ts +++ b/src/vs/platform/backup/node/backupMainService.ts @@ -63,7 +63,7 @@ export class BackupMainService implements IBackupMainService { // Allow sync here as it's only used in workbench initialization's critical path try { - return readdirSync(untitledDir).map(file => path.join(untitledDir, file)); + return readdirSync(untitledDir); } catch (ex) { return []; } diff --git a/src/vs/workbench/common/editor/untitledEditorInput.ts b/src/vs/workbench/common/editor/untitledEditorInput.ts index 17392c106b4..9a84351349b 100644 --- a/src/vs/workbench/common/editor/untitledEditorInput.ts +++ b/src/vs/workbench/common/editor/untitledEditorInput.ts @@ -157,9 +157,10 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput { let restorePromise: TPromise; if (this.hasBackupToRestore) { // TODO: Pass in only Untitled-x into the constructor, evaluate whether there is a backup here. - const restoreResource = URI.from({ scheme: 'file', path: this.resource.fsPath }); + const restoreResource = this.backupFileService.getBackupResource(this.resource); restorePromise = this.textFileService.resolveTextContent(restoreResource).then(rawTextContent => rawTextContent.value.lines.join('\n')); - this.resource = URI.from({ scheme: UntitledEditorInput.SCHEMA, path: paths.basename(this.resource.fsPath) }); + + // If the resource restored from backup it doesn't have an associated file path this.hasAssociatedFilePath = false; } else { restorePromise = TPromise.as(''); diff --git a/src/vs/workbench/electron-browser/main.ts b/src/vs/workbench/electron-browser/main.ts index a2283fee50d..d12f793e63c 100644 --- a/src/vs/workbench/electron-browser/main.ts +++ b/src/vs/workbench/electron-browser/main.ts @@ -58,7 +58,7 @@ export function startup(configuration: IWindowConfiguration): TPromise { const filesToOpen = configuration.filesToOpen && configuration.filesToOpen.length ? toInputs(configuration.filesToOpen) : null; const filesToCreate = configuration.filesToCreate && configuration.filesToCreate.length ? toInputs(configuration.filesToCreate) : null; const filesToDiff = configuration.filesToDiff && configuration.filesToDiff.length ? toInputs(configuration.filesToDiff) : null; - const untitledToRestore = configuration.untitledToRestore && configuration.untitledToRestore.length ? toInputs(configuration.untitledToRestore) : null; + const untitledToRestore = configuration.untitledToRestore && configuration.untitledToRestore.length ? toInputs(configuration.untitledToRestore, true) : null; const shellOptions: IOptions = { filesToOpen, filesToCreate, @@ -78,11 +78,15 @@ export function startup(configuration: IWindowConfiguration): TPromise { }); } -function toInputs(paths: IPath[]): IResourceInput[] { +function toInputs(paths: IPath[], isUntitledFile?: boolean): IResourceInput[] { return paths.map(p => { - const input = { - resource: uri.file(p.filePath) - }; + const input = {}; + + if (isUntitledFile) { + input.resource = uri.from({ scheme: 'untitled', path: p.filePath }); + } else { + input.resource = uri.file(p.filePath); + } if (p.lineNumber) { input.options = {