another fix for #15941

This commit is contained in:
Benjamin Pasero
2016-11-29 13:01:01 +01:00
parent 80757558f2
commit e70b8b6887
3 changed files with 14 additions and 6 deletions
@@ -97,9 +97,13 @@ class UntitledEditorInputFactory implements IEditorInputFactory {
public serialize(editorInput: EditorInput): string {
const untitledEditorInput = <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);
}
@@ -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<void>();
this._onDidModelChangeEncoding = new Emitter<void>();
}
public get hasAssociatedFilePath(): boolean {
return this._hasAssociatedFilePath;
}
public get onDidModelChangeContent(): Event<void> {
return this._onDidModelChangeContent.event;
}
@@ -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);
}