提交 7e3cfa3b 编写于 作者: B Benjamin Pasero

files - only emit onDidCreate after promise is stored in map

上级 33e78e09
......@@ -249,6 +249,7 @@ export class TextFileEditorModelManager extends Disposable implements ITextFileE
let modelPromise: Promise<ITextFileEditorModel>;
let model = this.get(resource);
let didCreateModel = false;
// Model exists
if (model) {
......@@ -271,6 +272,8 @@ export class TextFileEditorModelManager extends Disposable implements ITextFileE
// Model does not exist
else {
didCreateModel = true;
const newModel = model = this.instantiationService.createInstance(TextFileEditorModel, resource, options ? options.encoding : undefined, options ? options.mode : undefined);
modelPromise = model.load(options);
......@@ -285,14 +288,16 @@ export class TextFileEditorModelManager extends Disposable implements ITextFileE
listeners.add(model.onDidChangeOrphaned(() => this._onDidChangeOrphaned.fire(newModel)));
this.mapResourceToModelListeners.set(resource, listeners);
// Signal as event
this._onDidCreate.fire(newModel);
}
// Store pending loads to avoid race conditions
this.mapResourceToPendingModelLoaders.set(resource, modelPromise);
// Signal as event if we created the model
if (didCreateModel) {
this._onDidCreate.fire(model);
}
try {
const resolvedModel = await modelPromise;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册