Enable VS Code extension event APIs for when editors become active or visible. (#18129)

This commit is contained in:
Cory Rivera
2022-01-20 11:04:27 -08:00
committed by GitHub
parent 251901fee7
commit 470afe2e8a
2 changed files with 15 additions and 14 deletions

View File

@@ -22,6 +22,7 @@ import {
import { ExtHostNotebookDocumentData } from 'sql/workbench/api/common/extHostNotebookDocumentData';
import { ExtHostNotebookEditor } from 'sql/workbench/api/common/extHostNotebookEditor';
import { VSCodeNotebookDocument } from 'sql/workbench/api/common/notebooks/vscodeNotebookDocument';
import { VSCodeNotebookEditor } from 'sql/workbench/api/common/notebooks/vscodeNotebookEditor';
type Adapter = azdata.nb.NavigationProvider;
@@ -49,8 +50,12 @@ export class ExtHostNotebookDocumentsAndEditors implements ExtHostNotebookDocume
readonly onDidCloseNotebookDocument: Event<azdata.nb.NotebookDocument> = this._onDidCloseNotebook.event;
readonly onDidChangeNotebookCell: Event<azdata.nb.NotebookCellChangeEvent> = this._onDidChangeNotebookCell.event;
private _onDidOpenVSCodeNotebook = new Emitter<vscode.NotebookDocument>();
private _onDidCloseVSCodeNotebook = new Emitter<vscode.NotebookDocument>();
private readonly _onDidChangeVisibleVSCodeEditors = new Emitter<vscode.NotebookEditor[]>();
private readonly _onDidChangeActiveVSCodeEditor = new Emitter<vscode.NotebookEditor>();
private readonly _onDidOpenVSCodeNotebook = new Emitter<vscode.NotebookDocument>();
private readonly _onDidCloseVSCodeNotebook = new Emitter<vscode.NotebookDocument>();
readonly onDidChangeVisibleVSCodeEditors: Event<vscode.NotebookEditor[]> = this._onDidChangeVisibleVSCodeEditors.event;
readonly onDidChangeActiveVSCodeEditor: Event<vscode.NotebookEditor> = this._onDidChangeActiveVSCodeEditor.event;
readonly onDidOpenVSCodeNotebookDocument: Event<vscode.NotebookDocument> = this._onDidOpenVSCodeNotebook.event;
readonly onDidCloseVSCodeNotebookDocument: Event<vscode.NotebookDocument> = this._onDidCloseVSCodeNotebook.event;
@@ -61,6 +66,8 @@ export class ExtHostNotebookDocumentsAndEditors implements ExtHostNotebookDocume
this._proxy = this._mainContext.getProxy(SqlMainContext.MainThreadNotebookDocumentsAndEditors);
}
this.onDidChangeVisibleNotebookEditors(editors => this._onDidChangeVisibleVSCodeEditors.fire(editors.map(editor => new VSCodeNotebookEditor(editor))));
this.onDidChangeActiveNotebookEditor(editor => this._onDidChangeActiveVSCodeEditor.fire(new VSCodeNotebookEditor(editor)));
this.onDidOpenNotebookDocument(notebook => this._onDidOpenVSCodeNotebook.fire(new VSCodeNotebookDocument(notebook)));
this.onDidCloseNotebookDocument(notebook => this._onDidCloseVSCodeNotebook.fire(new VSCodeNotebookDocument(notebook)));
}

View File

@@ -724,22 +724,16 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor, ex
return new VSCodeNotebookEditor(extHostNotebookDocumentsAndEditors.getActiveEditor());
},
onDidChangeActiveNotebookEditor(listener, thisArgs?, disposables?) {
// {{SQL CARBON EDIT}} Disable VS Code notebooks
throw new Error(functionalityNotSupportedError);
// checkProposedApiEnabled(extension);
// return extHostNotebook.onDidChangeActiveNotebookEditor(listener, thisArgs, disposables);
// {{SQL CARBON EDIT}} Use our own notebooks
return extHostNotebookDocumentsAndEditors.onDidChangeActiveVSCodeEditor(listener, thisArgs, disposables);
},
get visibleNotebookEditors() {
// {{SQL CARBON EDIT}} Disable VS Code notebooks
return undefined;
// checkProposedApiEnabled(extension);
// return extHostNotebook.visibleNotebookEditors;
// {{SQL CARBON EDIT}} Use our own notebooks
return extHostNotebookDocumentsAndEditors.getAllEditors().map(editor => new VSCodeNotebookEditor(editor));
},
get onDidChangeVisibleNotebookEditors() {
// {{SQL CARBON EDIT}} Disable VS Code notebooks
return undefined;
// checkProposedApiEnabled(extension);
// return extHostNotebook.onDidChangeVisibleNotebookEditors;
// {{SQL CARBON EDIT}} Use our own notebooks
return extHostNotebookDocumentsAndEditors.onDidChangeVisibleVSCodeEditors;
},
onDidChangeNotebookEditorSelection(listener, thisArgs?, disposables?) {
// {{SQL CARBON EDIT}} Disable VS Code notebooks