提交 254e716f 编写于 作者: R rebornix

EditorInput/NotebookTextModel is N/1 mapping.

上级 03711748
......@@ -94,7 +94,9 @@ Registry.as<IEditorInputFactoryRegistry>(EditorInputExtensions.EditorInputFactor
return undefined;
}
const input = NotebookEditorInput.getOrCreate(instantiationService, resource, name, viewType);
// if we have two editors open with the same resource (in different editor groups), we should then create two different
// editor inputs, instead of `getOrCreate`.
const input = NotebookEditorInput.create(instantiationService, resource, name, viewType);
if (typeof data.group === 'number') {
input.updateGroup(data.group);
}
......@@ -245,7 +247,7 @@ export class NotebookContribution extends Disposable implements IWorkbenchContri
const name = basename(data.notebook);
let input = this._resourceMapping.get(data.notebook);
if (!input || input.isDisposed()) {
input = NotebookEditorInput.getOrCreate(this.instantiationService, data.notebook, name, info.id);
input = NotebookEditorInput.create(this.instantiationService, data.notebook, name, info.id);
this._resourceMapping.set(data.notebook, input);
}
......@@ -261,7 +263,7 @@ export class NotebookContribution extends Disposable implements IWorkbenchContri
return undefined;
}
const input = NotebookEditorInput.getOrCreate(this.instantiationService, resource, originalInput.getName(), info.id);
const input = NotebookEditorInput.create(this.instantiationService, resource, originalInput.getName(), info.id);
input.updateGroup(group.id);
this._resourceMapping.set(resource, input);
......
......@@ -14,23 +14,8 @@ import { IFileDialogService } from 'vs/platform/dialogs/common/dialogs';
let NOTEBOOK_EDITOR_INPUT_HANDLE = 0;
export class NotebookEditorInput extends EditorInput {
private static readonly _instances = new Map<string, NotebookEditorInput>();
static getOrCreate(instantiationService: IInstantiationService, resource: URI, name: string, viewType: string | undefined) {
const key = resource.toString() + viewType;
let input = NotebookEditorInput._instances.get(key);
if (!input) {
input = instantiationService.createInstance(class extends NotebookEditorInput {
dispose() {
NotebookEditorInput._instances.delete(key);
super.dispose();
}
}, resource, name, viewType);
NotebookEditorInput._instances.set(key, input);
}
return input;
static create(instantiationService: IInstantiationService, resource: URI, name: string, viewType: string | undefined) {
return instantiationService.createInstance(NotebookEditorInput, resource, name, viewType);
}
static readonly ID: string = 'workbench.input.notebook';
......@@ -132,7 +117,7 @@ export class NotebookEditorInput extends EditorInput {
}
_move(group: GroupIdentifier, newResource: URI): { editor: IEditorInput } | undefined {
const editorInput = NotebookEditorInput.getOrCreate(this.instantiationService, newResource, basename(newResource), this.viewType);
const editorInput = NotebookEditorInput.create(this.instantiationService, newResource, basename(newResource), this.viewType);
return { editor: editorInput };
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册