mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 11:08:51 +01:00
@@ -28,7 +28,6 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput {
|
||||
public static SCHEMA: string = 'untitled';
|
||||
|
||||
private resource: URI;
|
||||
private restoreResource: URI;
|
||||
private hasAssociatedFilePath: boolean;
|
||||
private modeId: string;
|
||||
private cachedModel: UntitledEditorModel;
|
||||
@@ -47,6 +46,7 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput {
|
||||
@ITextFileService private textFileService: ITextFileService
|
||||
) {
|
||||
super();
|
||||
|
||||
this.resource = resource;
|
||||
this.hasAssociatedFilePath = hasAssociatedFilePath;
|
||||
this.modeId = modeId;
|
||||
@@ -66,10 +66,6 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput {
|
||||
return this.resource;
|
||||
}
|
||||
|
||||
public setRestoreResource(resource: URI): void {
|
||||
this.restoreResource = resource;
|
||||
}
|
||||
|
||||
public getName(): string {
|
||||
return this.hasAssociatedFilePath ? paths.basename(this.resource.fsPath) : this.resource.fsPath;
|
||||
}
|
||||
@@ -134,25 +130,17 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput {
|
||||
return TPromise.as(this.cachedModel);
|
||||
}
|
||||
|
||||
// Otherwise Create Model and load, restoring from backup if necessary
|
||||
let restorePromise: TPromise<string>;
|
||||
if (this.restoreResource) {
|
||||
restorePromise = this.textFileService.resolveTextContent(this.restoreResource).then(rawTextContent => rawTextContent.value.lines.join('\n'));
|
||||
} else {
|
||||
restorePromise = TPromise.as('');
|
||||
}
|
||||
// Otherwise Create Model and load
|
||||
const model = this.createModel();
|
||||
return model.load().then((resolvedModel: UntitledEditorModel) => {
|
||||
this.cachedModel = resolvedModel;
|
||||
|
||||
return restorePromise.then(content => {
|
||||
const model = this.createModel(content);
|
||||
return model.load().then((resolvedModel: UntitledEditorModel) => {
|
||||
this.cachedModel = resolvedModel;
|
||||
|
||||
return this.cachedModel;
|
||||
});
|
||||
return this.cachedModel;
|
||||
});
|
||||
}
|
||||
|
||||
private createModel(content: string): UntitledEditorModel {
|
||||
private createModel(): UntitledEditorModel {
|
||||
const content = '';
|
||||
const model = this.instantiationService.createInstance(UntitledEditorModel, content, this.modeId, this.resource, this.hasAssociatedFilePath);
|
||||
|
||||
// re-emit some events from the model
|
||||
|
||||
Reference in New Issue
Block a user