diff --git a/src/vs/workbench/api/browser/mainThreadNotebook.ts b/src/vs/workbench/api/browser/mainThreadNotebook.ts index d9a61aa4f42b4f42153a475eca9b7a94591afa9f..7fdf21501fff33cba1a87bce1357b10f91446701 100644 --- a/src/vs/workbench/api/browser/mainThreadNotebook.ts +++ b/src/vs/workbench/api/browser/mainThreadNotebook.ts @@ -415,7 +415,13 @@ export class MainThreadNotebooks extends Disposable implements MainThreadNoteboo } async $registerNotebookRenderer(extension: NotebookExtensionDescription, type: string, selectors: INotebookMimeTypeSelector, preloads: UriComponents[]): Promise { - const renderer = new MainThreadNotebookRenderer(this._proxy, type, extension.id, URI.revive(extension.location), selectors, preloads.map(uri => URI.revive(uri))); + const staticContribution = this._notebookService.getContributedNotebookOutputRenderers(type); + + if (!staticContribution) { + throw new Error(`Notebook renderer for '${type}' is not statically registered.`); + } + + const renderer = new MainThreadNotebookRenderer(this._proxy, type, staticContribution.displayName, extension.id, URI.revive(extension.location), selectors, preloads.map(uri => URI.revive(uri))); this._notebookRenderers.set(type, renderer); this._notebookService.registerNotebookRenderer(type, renderer); } @@ -674,10 +680,11 @@ export class MainThreadNotebookRenderer implements INotebookRendererInfo { constructor( private readonly _proxy: ExtHostNotebookShape, readonly id: string, + public displayName: string, readonly extensionId: ExtensionIdentifier, readonly extensionLocation: URI, readonly selectors: INotebookMimeTypeSelector, - readonly preloads: URI[] + readonly preloads: URI[], ) { } diff --git a/src/vs/workbench/api/common/extHostNotebook.ts b/src/vs/workbench/api/common/extHostNotebook.ts index 6452d5a398535fbd5e9fbc741bc4c3d9eca99a5e..037b0c71e63a9ff2c69b845bbf179826b4d6b644 100644 --- a/src/vs/workbench/api/common/extHostNotebook.ts +++ b/src/vs/workbench/api/common/extHostNotebook.ts @@ -964,7 +964,7 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN filter: vscode.NotebookOutputSelector, renderer: vscode.NotebookOutputRenderer ): vscode.Disposable { - if (this._notebookKernels.has(type)) { + if (this._notebookOutputRenderers.has(type)) { throw new Error(`Notebook renderer for '${type}' already registered`); } diff --git a/src/vs/workbench/contrib/notebook/browser/notebookPureOutputRenderer.ts b/src/vs/workbench/contrib/notebook/browser/notebookPureOutputRenderer.ts index c1f42f14d6cfd39ad03cc6263bd96ff2f6c4cf82..af6c59fc4ed98a6a14e08311a2bbd21f241b141f 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebookPureOutputRenderer.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebookPureOutputRenderer.ts @@ -19,7 +19,7 @@ export class PureNotebookOutputRenderer implements INotebookRendererInfo { public readonly preloads: URI[]; - constructor(public readonly id: string, extension: IExtensionDescription, entrypoint: string) { + constructor(public readonly id: string, public readonly displayName: string, extension: IExtensionDescription, entrypoint: string) { this.extensionId = extension.identifier; this.extensionLocation = extension.extensionLocation; this.preloads = [joinPath(extension.extensionLocation, entrypoint)]; diff --git a/src/vs/workbench/contrib/notebook/browser/notebookServiceImpl.ts b/src/vs/workbench/contrib/notebook/browser/notebookServiceImpl.ts index b5c95859442bc835a34279cf02f7780418c5cac9..a45e3a397c0345ae7a0d6ad0a76ee9a1c2a5c8f7 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebookServiceImpl.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebookServiceImpl.ts @@ -298,7 +298,7 @@ export class NotebookService extends Disposable implements INotebookService, ICu })); if (notebookContribution.entrypoint) { - this._notebookRenderers.set(notebookContribution.viewType, new PureNotebookOutputRenderer(notebookContribution.viewType, extension.description, notebookContribution.entrypoint)); + this._notebookRenderers.set(notebookContribution.viewType, new PureNotebookOutputRenderer(notebookContribution.viewType, notebookContribution.displayName, extension.description, notebookContribution.entrypoint)); } } } @@ -547,6 +547,11 @@ export class NotebookService extends Disposable implements INotebookService, ICu registerNotebookRenderer(id: string, renderer: INotebookRendererInfo) { this._notebookRenderers.set(id, renderer); + const staticInfo = this.notebookRenderersInfoStore.get(id); + + if (staticInfo) { + + } } unregisterNotebookRenderer(id: string) { @@ -995,8 +1000,8 @@ export class NotebookService extends Disposable implements INotebookService, ICu return this.notebookProviderInfoStore.get(viewType); } - getContributedNotebookOutputRenderers(mimeType: string): readonly NotebookOutputRendererInfo[] { - return this.notebookRenderersInfoStore.getContributedRenderer(mimeType); + getContributedNotebookOutputRenderers(viewType: string): NotebookOutputRendererInfo | undefined { + return this.notebookRenderersInfoStore.get(viewType); } getNotebookProviderResourceRoots(): URI[] { diff --git a/src/vs/workbench/contrib/notebook/browser/view/renderers/codeCell.ts b/src/vs/workbench/contrib/notebook/browser/view/renderers/codeCell.ts index c541cb9b136c500427b44c09c3556d610ee81deb..ef7e8c202a17663c55b73e66f9099b704bb9e1bd 100644 --- a/src/vs/workbench/contrib/notebook/browser/view/renderers/codeCell.ts +++ b/src/vs/workbench/contrib/notebook/browser/view/renderers/codeCell.ts @@ -558,7 +558,8 @@ export class CodeCell extends Disposable { const renderInfo = this.notebookService.getRendererInfo(renderId); if (renderInfo) { - return `${renderId} (${renderInfo.extensionId.value})`; + const displayName = renderInfo.displayName !== '' ? renderInfo.displayName : renderInfo.id; + return `${displayName} (${renderInfo.extensionId.value})`; } return nls.localize('builtinRenderInfo', "built-in"); diff --git a/src/vs/workbench/contrib/notebook/common/notebookCommon.ts b/src/vs/workbench/contrib/notebook/common/notebookCommon.ts index 46c9f3f0ec53437383079478edb6418a8ed2c97d..319c8fd913009a4184a717b48c5e727a2e0a8468 100644 --- a/src/vs/workbench/contrib/notebook/common/notebookCommon.ts +++ b/src/vs/workbench/contrib/notebook/common/notebookCommon.ts @@ -113,6 +113,7 @@ export interface INotebookMimeTypeSelector { export interface INotebookRendererInfo { id: string; + displayName: string; extensionId: ExtensionIdentifier; extensionLocation: URI, preloads: URI[], diff --git a/src/vs/workbench/contrib/notebook/common/notebookService.ts b/src/vs/workbench/contrib/notebook/common/notebookService.ts index 9c6d199d7edd61420fc2efc02bc02784ff20d4f9..87fad7fb364283a070eb38bf2245933dea0350ec 100644 --- a/src/vs/workbench/contrib/notebook/common/notebookService.ts +++ b/src/vs/workbench/contrib/notebook/common/notebookService.ts @@ -16,6 +16,7 @@ import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/no import { CancellationToken } from 'vs/base/common/cancellation'; import { NotebookCellTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookCellTextModel'; import { IDisposable } from 'vs/base/common/lifecycle'; +import { NotebookOutputRendererInfo } from 'vs/workbench/contrib/notebook/common/notebookOutputRenderer'; export const INotebookService = createDecorator('notebookService'); @@ -61,7 +62,9 @@ export interface INotebookService { registerNotebookKernelProvider(provider: INotebookKernelProvider): IDisposable; getContributedNotebookKernels(viewType: string, resource: URI): readonly INotebookKernelInfo[]; getContributedNotebookKernels2(viewType: string, resource: URI, token: CancellationToken): Promise; + getContributedNotebookOutputRenderers(id: string): NotebookOutputRendererInfo | undefined; getRendererInfo(id: string): INotebookRendererInfo | undefined; + resolveNotebook(viewType: string, uri: URI, forceReload: boolean, editorId?: string, backupId?: string): Promise; getNotebookTextModel(uri: URI): NotebookTextModel | undefined; executeNotebook(viewType: string, uri: URI): Promise;