Add support for VS Code notebook Open & Close events in extension APIs (#17992)

This commit is contained in:
Cory Rivera
2022-01-07 15:48:08 -08:00
committed by GitHub
parent 4b9c43848e
commit d13dd4d228
9 changed files with 276 additions and 87 deletions

View File

@@ -93,6 +93,7 @@ import { matchesScheme } from 'vs/platform/opener/common/opener';
// import { ExtHostInteractive } from 'vs/workbench/api/common/extHostInteractive'; {{SQL CARBON EDIT}} Remove until we need it
import { ExtHostNotebook } from 'sql/workbench/api/common/extHostNotebook';
import { functionalityNotSupportedError } from 'sql/base/common/locConstants';
import { ExtHostNotebookDocumentsAndEditors } from 'sql/workbench/api/common/extHostNotebookDocumentsAndEditors';
export interface IExtensionApiFactory {
(extension: IExtensionDescription, registry: ExtensionDescriptionRegistry, configProvider: ExtHostConfigProvider): typeof vscode;
@@ -101,7 +102,7 @@ export interface IExtensionApiFactory {
/**
* This method instantiates and returns the extension API surface
*/
export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor, extHostNotebook: ExtHostNotebook): IExtensionApiFactory { // {{SQL CARBON EDIT}} Add ExtHostNotebook
export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor, extHostNotebook: ExtHostNotebook, extHostNotebookDocumentsAndEditors: ExtHostNotebookDocumentsAndEditors): IExtensionApiFactory { // {{SQL CARBON EDIT}} Add ExtHostNotebook
// services
const initData = accessor.get(IExtHostInitDataService);
@@ -902,16 +903,15 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor, ex
// return extHostNotebook.getNotebookDocument(uri).apiNotebook;
},
get onDidOpenNotebookDocument(): Event<vscode.NotebookDocument> {
// {{SQL CARBON EDIT}} Disable VS Code notebooks
throw new Error(functionalityNotSupportedError);
// return extHostNotebook.onDidOpenNotebookDocument;
// {{SQL CARBON EDIT}} Use our own notebooks
return extHostNotebookDocumentsAndEditors.onDidOpenVSCodeNotebookDocument;
},
get onDidCloseNotebookDocument(): Event<vscode.NotebookDocument> {
// {{SQL CARBON EDIT}} Disable VS Code notebooks
throw new Error(functionalityNotSupportedError);
// return extHostNotebook.onDidCloseNotebookDocument;
// {{SQL CARBON EDIT}} Use our own notebooks
return extHostNotebookDocumentsAndEditors.onDidCloseVSCodeNotebookDocument;
},
registerNotebookSerializer(viewType: string, serializer: vscode.NotebookSerializer, options?: vscode.NotebookDocumentContentOptions, registration?: vscode.NotebookRegistrationData) {
// {{SQL CARBON EDIT}} Use our own notebooks
return extHostNotebook.registerNotebookSerializer(viewType, serializer, options, extension.enableProposedApi ? registration : undefined);
},
registerNotebookContentProvider: (viewType: string, provider: vscode.NotebookContentProvider, options?: vscode.NotebookDocumentContentOptions, registration?: vscode.NotebookRegistrationData) => {
@@ -1152,6 +1152,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor, ex
// namespace: notebook
const notebooks: typeof vscode.notebooks = {
createNotebookController(id: string, notebookType: string, label: string, handler?, rendererScripts?: vscode.NotebookRendererScript[]) {
// {{SQL CARBON EDIT}} Use our own notebooks
return extHostNotebook.createNotebookController(extension, id, notebookType, label, handler, extension.enableProposedApi ? rendererScripts : undefined);
},
registerNotebookCellStatusBarItemProvider: (notebookType: string, provider: vscode.NotebookCellStatusBarItemProvider) => {