提交 e70b8b68 编写于 作者: B Benjamin Pasero

another fix for #15941

上级 80757558
......@@ -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);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册