Skip to content

Commit

Permalink
fix cell link regression, remove diagnostic log
Browse files Browse the repository at this point in the history
  • Loading branch information
amunger committed Nov 1, 2023
1 parent 08f1c3d commit b45119e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class InteractiveEditorInput extends EditorInput implements ICompositeNot
@INotebookService private readonly _notebookService: INotebookService,
@IFileDialogService private readonly _fileDialogService: IFileDialogService
) {
const input = NotebookEditorInput.create(instantiationService, resource, undefined, 'interactive', {});
const input = NotebookEditorInput.getOrCreate(instantiationService, resource, undefined, 'interactive', {});
super();
this._notebookEditorInput = input;
this._register(this._notebookEditorInput);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class NotebookEditorSerializer implements IEditorSerializer {
return undefined;
}

const input = NotebookEditorInput.create(instantiationService, resource, preferredResource, viewType, options);
const input = NotebookEditorInput.getOrCreate(instantiationService, resource, preferredResource, viewType, options);
return input;
}
}
Expand Down Expand Up @@ -640,7 +640,7 @@ class SimpleNotebookWorkingCopyEditorHandler extends Disposable implements IWork
}

createEditor(workingCopy: IWorkingCopyIdentifier): EditorInput {
return NotebookEditorInput.create(this._instantiationService, workingCopy.resource, undefined, this._getViewType(workingCopy)!);
return NotebookEditorInput.getOrCreate(this._instantiationService, workingCopy.resource, undefined, this._getViewType(workingCopy)!);
}

private async _installHandler(): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export class NotebookProviderInfoStore extends Disposable {
// resource is a notebook cell
notebookUri = this.uriIdentService.asCanonicalUri(data.notebook);
preferredResource = data.notebook;
cellOptions = { resource: notebookUri, options };
cellOptions = { resource, options };
} else {
notebookUri = this.uriIdentService.asCanonicalUri(resource);
}
Expand All @@ -199,7 +199,7 @@ export class NotebookProviderInfoStore extends Disposable {
}

const notebookOptions = { ...options, cellOptions } as INotebookEditorOptions;
const editor = NotebookEditorInput.create(this._instantiationService, notebookUri, preferredResource, notebookProviderInfo.id);
const editor = NotebookEditorInput.getOrCreate(this._instantiationService, notebookUri, preferredResource, notebookProviderInfo.id);
return { editor, options: notebookOptions };
};

Expand All @@ -212,7 +212,7 @@ export class NotebookProviderInfoStore extends Disposable {
ref!.dispose();
});

return { editor: NotebookEditorInput.create(this._instantiationService, ref.object.resource, undefined, notebookProviderInfo.id), options };
return { editor: NotebookEditorInput.getOrCreate(this._instantiationService, ref.object.resource, undefined, notebookProviderInfo.id), options };
};
const notebookDiffEditorInputFactory: DiffEditorInputFactoryFunction = ({ modified, original, label, description }) => {
return { editor: NotebookDiffEditorInput.create(this._instantiationService, modified.resource!, label, description, original.resource!, notebookProviderInfo.id) };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class NotebookDiffEditorModel extends EditorModel implements INotebookDiffEditor

export class NotebookDiffEditorInput extends DiffEditorInput {
static create(instantiationService: IInstantiationService, resource: URI, name: string | undefined, description: string | undefined, originalResource: URI, viewType: string) {
const original = NotebookEditorInput.create(instantiationService, originalResource, undefined, viewType);
const modified = NotebookEditorInput.create(instantiationService, resource, undefined, viewType);
const original = NotebookEditorInput.getOrCreate(instantiationService, originalResource, undefined, viewType);
const modified = NotebookEditorInput.getOrCreate(instantiationService, resource, undefined, viewType);
return instantiationService.createInstance(NotebookDiffEditorInput, name, description, original, modified, viewType);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ export class NotebookEditorInput extends AbstractResourceEditorInput {

private static EditorCache: Record<string, NotebookEditorInput> = {};

static create(instantiationService: IInstantiationService, resource: URI, preferredResource: URI | undefined, viewType: string, options: NotebookEditorInputOptions = {}) {
static getOrCreate(instantiationService: IInstantiationService, resource: URI, preferredResource: URI | undefined, viewType: string, options: NotebookEditorInputOptions = {}) {
const cacheId = `${resource.toString()}|${viewType}|${options._workingCopy?.typeId}`;
let editor = NotebookEditorInput.EditorCache[cacheId];

if (!editor) {
editor = instantiationService.createInstance(NotebookEditorInput, resource, preferredResource, viewType, options);
NotebookEditorInput.EditorCache[resource.toString()] = editor;
NotebookEditorInput.EditorCache[cacheId] = editor;

editor.onWillDispose(() => {
delete NotebookEditorInput.EditorCache[cacheId];
Expand All @@ -67,9 +67,6 @@ export class NotebookEditorInput extends AbstractResourceEditorInput {
private _sideLoadedListener: IDisposable;
private _defaultDirtyState: boolean = false;

static counter = 1;
private debugId = NotebookEditorInput.counter++;

constructor(
resource: URI,
preferredResource: URI | undefined,
Expand All @@ -87,7 +84,6 @@ export class NotebookEditorInput extends AbstractResourceEditorInput {
super(resource, preferredResource, labelService, fileService, filesConfigurationService);
this._defaultDirtyState = !!options.startDirty;

console.log(`Creating notebookEditorInput ${this.debugId}`);
// Automatically resolve this input when the "wanted" model comes to life via
// some other way. This happens only once per input and resolve disposes
// this listener
Expand Down Expand Up @@ -116,7 +112,6 @@ export class NotebookEditorInput extends AbstractResourceEditorInput {
}

override dispose() {
console.log(`Disposing notebokEditorInput ${this.debugId}`);
this._sideLoadedListener.dispose();
this._editorModelReference?.dispose();
this._editorModelReference = null;
Expand Down

0 comments on commit b45119e

Please sign in to comment.