src/vs/workbench/contrib/notebook/browser/notebookEditor.ts/NotebookEditor/setInput
class NotebookEditor:	override async setInput(input: NotebookEditorInput, options: INotebookEditorOptions | undefined, context: IEditorOpenContext, token: CancellationToken, noRetry?: boolean): Promise<void> {
		try {
			clearMarks(input.resource);
			mark(input.resource, 'startTime');
			const group = this.group!;

			this._inputListener.value = input.onDidChangeCapabilities(() => this._onDidChangeInputCapabilities(input));

			this._widgetDisposableStore.clear();

			// there currently is a widget which we still own so
			// we need to hide it before getting a new widget
			if (this._widget.value) {
				this._widget.value.onWillHide();
			}

			this._widget = <IBorrowValue<NotebookEditorWidget>>this._instantiationService.invokeFunction(this._notebookWidgetService.retrieveWidget, group, input);

			if (this._rootElement && this._widget.value!.getDomNode()) {
				this._rootElement.setAttribute('aria-flowto', this._widget.value!.getDomNode().id || '');
				DOM.setParentFlowTo(this._widget.value!.getDomNode(), this._rootElement);
			}

			this._widgetDisposableStore.add(this._widget.value!.onDidChangeModel(() => this._onDidChangeModel.fire()));
			this._widgetDisposableStore.add(this._widget.value!.onDidChangeActiveCell(() => this._onDidChangeSelection.fire({ reason: EditorPaneSelectionChangeReason.USER })));

			if (this._dimension) {
				this._widget.value!.layout(this._dimension, this._rootElement);
			}

			// only now `setInput` and yield/await. this is AFTER the actual widget is ready. This is very important
			// so that others synchronously receive a notebook editor with the correct widget being set
			await super.setInput(input, options, context, token);
			const model = await input.resolve();
			mark(input.resource, 'inputLoaded');

			// Check for cancellation
			if (token.isCancellationRequested) {
				return undefined;
			}

			// The widget has been taken away again. This can happen when the tab has been closed while
			// loading was in progress, in particular when open the same resource as different view type.
			// When this happen, retry once
			if (!this._widget.value) {
				if (noRetry) {
					return undefined;
				}
				return this.setInput(input, options, context, token, true);
			}

			if (model === null) {
				throw new Error(localize('fail.noEditor', "Cannot open resource with notebook editor type '{0}', please check if you have the right extension installed and enabled.", input.viewType));
			}

			this._widgetDisposableStore.add(model.notebook.onDidChangeContent(() => this._onDidChangeSelection.fire({ reason: EditorPaneSelectionChangeReason.EDIT })));

			const viewState = options?.viewState ?? this._loadNotebookEditorViewState(input);

			this._widget.value?.setParentContextKeyService(this._contextKeyService);
			await this._widget.value!.setModel(model.notebook, viewState);
			const isReadOnly = input.hasCapability(EditorInputCapabilities.Readonly);
			await this._widget.value!.setOptions({ ...options, isReadOnly });
			this._widgetDisposableStore.add(this._widget.value!.onDidFocusWidget(() => this._onDidFocusWidget.fire()));
			this._widgetDisposableStore.add(this._widget.value!.onDidBlurWidget(() => this._onDidBlurWidget.fire()));

			this._widgetDisposableStore.add(this._editorDropService.createEditorDropTarget(this._widget.value!.getDomNode(), {
				containsGroup: (group) => this.group?.id === group.id
			}));

			mark(input.resource, 'editorLoaded');

			type WorkbenchNotebookOpenClassification = {
				owner: 'rebornix';
				scheme: { classification: 'SystemMetaData'; purpose: 'FeatureInsight' };
				ext: { classification: 'SystemMetaData'; purpose: 'FeatureInsight' };
				viewType: { classification: 'SystemMetaData'; purpose: 'FeatureInsight' };
				extensionActivated: { classification: 'SystemMetaData'; purpose: 'FeatureInsight' };
				inputLoaded: { classification: 'SystemMetaData'; purpose: 'FeatureInsight' };
				webviewCommLoaded: { classification: 'SystemMetaData'; purpose: 'FeatureInsight' };
				customMarkdownLoaded: { classification: 'SystemMetaData'; purpose: 'FeatureInsight' };
				editorLoaded: { classification: 'SystemMetaData'; purpose: 'FeatureInsight' };
			};

			type WorkbenchNotebookOpenEvent = {
				scheme: string;
				ext: string;
				viewType: string;
				extensionActivated: number;
				inputLoaded: number;
				webviewCommLoaded: number;
				customMarkdownLoaded: number;
				editorLoaded: number;
			};

			const perfMarks = getAndClearMarks(input.resource);

			if (perfMarks) {
				const startTime = perfMarks['startTime'];
				const extensionActivated = perfMarks['extensionActivated'];
				const inputLoaded = perfMarks['inputLoaded'];
				const customMarkdownLoaded = perfMarks['customMarkdownLoaded'];
				const editorLoaded = perfMarks['editorLoaded'];

				if (
					startTime !== undefined
					&& extensionActivated !== undefined
					&& inputLoaded !== undefined
					&& customMarkdownLoaded !== undefined
					&& editorLoaded !== undefined
				) {
					this.telemetryService.publicLog2<WorkbenchNotebookOpenEvent, WorkbenchNotebookOpenClassification>('notebook/editorOpenPerf', {
						scheme: model.notebook.uri.scheme,
						ext: extname(model.notebook.uri),
						viewType: model.notebook.viewType,
						extensionActivated: extensionActivated - startTime,
						inputLoaded: inputLoaded - startTime,
						webviewCommLoaded: inputLoaded - startTime,
						customMarkdownLoaded: customMarkdownLoaded - startTime,
						editorLoaded: editorLoaded - startTime
					});
				} else {
					console.warn(`notebook file open perf marks are broken: startTime ${startTime}, extensionActiviated ${extensionActivated}, inputLoaded ${inputLoaded}, customMarkdownLoaded ${customMarkdownLoaded}, editorLoaded ${editorLoaded}`);
				}
			}
		} catch (e) {
			const error = createErrorWithActions(e instanceof Error ? e : new Error(e.message), [
				toAction({
					id: 'workbench.notebook.action.openInTextEditor', label: localize('notebookOpenInTextEditor', "Open in Text Editor"), run: async () => {
						const activeEditorPane = this._editorService.activeEditorPane;
						if (!activeEditorPane) {
							return;
						}

						const activeEditorResource = EditorResourceAccessor.getCanonicalUri(activeEditorPane.input);
						if (!activeEditorResource) {
							return;
						}

						if (activeEditorResource.toString() === input.resource?.toString()) {
							// Replace the current editor with the text editor
							return this._editorService.openEditor({
								resource: activeEditorResource,
								options: {
									override: DEFAULT_EDITOR_ASSOCIATION.id,
									pinned: true // new file gets pinned by default
								}
							});
						}

						return;
					}
				})
			]);

			throw error;
		}
	}