diff --git a/src/vs/workbench/browser/parts/editor/editor.contribution.ts b/src/vs/workbench/browser/parts/editor/editor.contribution.ts index c4e1dbeaa98..fa0ec153cf4 100644 --- a/src/vs/workbench/browser/parts/editor/editor.contribution.ts +++ b/src/vs/workbench/browser/parts/editor/editor.contribution.ts @@ -97,9 +97,13 @@ class UntitledEditorInputFactory implements IEditorInputFactory { public serialize(editorInput: EditorInput): string { const untitledEditorInput = editorInput; - const serialized: ISerializedUntitledEditorInput = { - resource: untitledEditorInput.getResource().toString() - }; + + let resource = untitledEditorInput.getResource(); + if (untitledEditorInput.hasAssociatedFilePath) { + resource = URI.file(resource.fsPath); // untitled with associated file path use the file schema + } + + const serialized: ISerializedUntitledEditorInput = { resource: resource.toString() }; return JSON.stringify(serialized); } diff --git a/src/vs/workbench/common/editor/untitledEditorInput.ts b/src/vs/workbench/common/editor/untitledEditorInput.ts index 4d2dccad3c6..67fa5424347 100644 --- a/src/vs/workbench/common/editor/untitledEditorInput.ts +++ b/src/vs/workbench/common/editor/untitledEditorInput.ts @@ -28,7 +28,7 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput { public static SCHEMA: string = 'untitled'; private resource: URI; - private hasAssociatedFilePath: boolean; + private _hasAssociatedFilePath: boolean; private modeId: string; private cachedModel: UntitledEditorModel; @@ -49,13 +49,17 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput { super(); this.resource = resource; - this.hasAssociatedFilePath = hasAssociatedFilePath; + this._hasAssociatedFilePath = hasAssociatedFilePath; this.modeId = modeId; this.toUnbind = []; this._onDidModelChangeContent = new Emitter(); this._onDidModelChangeEncoding = new Emitter(); } + public get hasAssociatedFilePath(): boolean { + return this._hasAssociatedFilePath; + } + public get onDidModelChangeContent(): Event { return this._onDidModelChangeContent.event; } diff --git a/src/vs/workbench/services/untitled/common/untitledEditorService.ts b/src/vs/workbench/services/untitled/common/untitledEditorService.ts index 3749c9a1416..df195bc70d4 100644 --- a/src/vs/workbench/services/untitled/common/untitledEditorService.ts +++ b/src/vs/workbench/services/untitled/common/untitledEditorService.ts @@ -180,7 +180,7 @@ export class UntitledEditorService implements IUntitledEditorService { // Create new taking a resource URI that is not already taken let counter = Object.keys(UntitledEditorService.CACHE).length + 1; do { - resource = URI.from({ scheme: UntitledEditorInput.SCHEMA, path: 'Untitled-' + counter }); + resource = URI.from({ scheme: UntitledEditorInput.SCHEMA, path: `Untitled-${counter}` }); counter++; } while (Object.keys(UntitledEditorService.CACHE).indexOf(resource.toString()) >= 0); }