提交 757968eb 编写于 作者: B Benjamin Pasero

resource input does not dispose model anymore

上级 cf922e64
......@@ -22,6 +22,7 @@ import {IModelService} from 'vs/editor/common/services/modelService';
*/
export abstract class BaseTextEditorModel extends EditorModel implements ITextEditorModel {
private textEditorModelHandle: URI;
private createdEditorModel: boolean;
constructor(
@IModelService private modelService: IModelService,
......@@ -46,6 +47,7 @@ export abstract class BaseTextEditorModel extends EditorModel implements ITextEd
// To avoid flickering, give the mode at most 50ms to load. If the mode doesn't load in 50ms, proceed creating the model with a mode promise
return Promise.any([Promise.timeout(50), this.getOrCreateMode(this.modeService, mime, firstLineText)]).then(() => {
let model = this.modelService.createModel(value, this.getOrCreateMode(this.modeService, mime, firstLineText), resource);
this.createdEditorModel = true;
this.textEditorModelHandle = model.getAssociatedResource();
......@@ -124,11 +126,12 @@ export abstract class BaseTextEditorModel extends EditorModel implements ITextEd
}
public dispose(): void {
if (this.textEditorModelHandle) {
if (this.textEditorModelHandle && this.createdEditorModel) {
this.modelService.destroyModel(this.textEditorModelHandle);
}
this.textEditorModelHandle = null;
this.createdEditorModel = false;
super.dispose();
}
......
......@@ -13,6 +13,7 @@ import URI from 'vs/base/common/uri';
import {EditorModel} from 'vs/workbench/common/editor';
import {guessMimeTypes} from 'vs/base/common/mime';
import {EditorInputAction} from 'vs/workbench/browser/parts/editor/baseEditor';
import {IModel} from 'vs/editor/common/editorCommon';
import {ResourceEditorInput} from 'vs/workbench/browser/parts/editor/resourceEditorInput';
import {DiffEditorInput} from 'vs/workbench/browser/parts/editor/diffEditorInput';
import {DiffEditorModel} from 'vs/workbench/browser/parts/editor/diffEditorModel';
......@@ -142,6 +143,7 @@ export class FileOnDiskEditorInput extends ResourceEditorInput {
private fileResource: URI;
private lastModified: number;
private mime: string;
private createdEditorModel: boolean;
constructor(
fileResource: URI,
......@@ -175,6 +177,7 @@ export class FileOnDiskEditorInput extends ResourceEditorInput {
let codeEditorModel = this.modelService.getModel(this.resource);
if (!codeEditorModel) {
this.modelService.createModel(content.value, this.modeService.getOrCreateMode(this.mime), this.resource);
this.createdEditorModel = true;
} else {
codeEditorModel.setValue(content.value);
}
......@@ -182,6 +185,15 @@ export class FileOnDiskEditorInput extends ResourceEditorInput {
return super.resolve(refresh);
});
}
public dispose(): void {
if (this.createdEditorModel) {
this.modelService.destroyModel(this.resource);
this.createdEditorModel = false;
}
super.dispose();
}
}
// A message with action to resolve a 412 save conflict
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册