From e43c3957f64a9f231734818aa8f72e139dd1e01e Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Thu, 3 Jun 2021 11:26:45 +0200 Subject: [PATCH] rename onDidChangeNotebookAssociation to onDidChangeSelectedNotebooks --- .vscode/searches/api-todos.code-search | 6 +----- .../src/singlefolder-tests/notebook.test.ts | 2 +- src/vs/vscode.d.ts | 17 +++++++++++------ .../api/common/extHostNotebookKernels.ts | 2 +- .../notebook/test/notebookKernelService.test.ts | 4 ++-- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.vscode/searches/api-todos.code-search b/.vscode/searches/api-todos.code-search index d4c87bda5e5..a475292d916 100644 --- a/.vscode/searches/api-todos.code-search +++ b/.vscode/searches/api-todos.code-search @@ -2,13 +2,9 @@ # Including: */vscode.d.ts # ContextLines: 1 -2 results - 1 file +1 result - 1 file src/vs/vscode.d.ts: 11804 */ 11805: //todo@API inline? 11806 export interface NotebookExecuteHandler { - - 11935 */ - 11936: //todo@api selected vs associated, jsdoc - 11937 readonly onDidChangeNotebookAssociation: Event<{ notebook: NotebookDocument, selected: boolean }>; diff --git a/extensions/vscode-api-tests/src/singlefolder-tests/notebook.test.ts b/extensions/vscode-api-tests/src/singlefolder-tests/notebook.test.ts index 41825cfb551..0e8dc300ed4 100644 --- a/extensions/vscode-api-tests/src/singlefolder-tests/notebook.test.ts +++ b/extensions/vscode-api-tests/src/singlefolder-tests/notebook.test.ts @@ -40,7 +40,7 @@ class Kernel { this.controller.executeHandler = this._execute.bind(this); this.controller.supportsExecutionOrder = true; this.controller.supportedLanguages = ['typescript', 'javascript']; - this.controller.onDidChangeNotebookAssociation(e => { + this.controller.onDidChangeSelectedNotebooks(e => { if (e.selected) { this.associatedNotebooks.add(e.notebook.uri.toString()); } else { diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index 74f694427a2..1beab46a6dd 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -11834,7 +11834,8 @@ declare module 'vscode' { * There can be multiple controllers and the editor will let users choose which controller to use for a certain notebook. The * {@link NotebookController.notebookType `notebookType`}-property defines for what kind of notebooks a controller is for and * the {@link NotebookController.updateNotebookAffinity `updateNotebookAffinity`}-function allows controllers to set a preference - * for specific notebook documents. + * for specific notebook documents. When a controller has been selected its + * {@link NotebookController.onDidChangeSelectedNotebooks onDidChangeSelectedNotebooks}-event fires. * * When a cell is being run the editor will invoke the {@link NotebookController.executeHandler `executeHandler`} and a controller * is expected to create and finalize a {@link NotebookCellExecution notebook cell execution}. However, controllers are also free @@ -11929,12 +11930,16 @@ declare module 'vscode' { interruptHandler?: (notebook: NotebookDocument) => void | Thenable; /** - * An event that fires whenever a controller has been selected for a notebook document. Selecting a controller - * for a notebook is a user gesture and happens either explicitly or implicitly when interacting while a - * controller was suggested. + * An event that fires whenever a controller has been selected or un-selected for a notebook document. + * + * There can be multiple controllers for a notebook and in that case a controllers needs to be _selected_. This is a user gesture + * and happens either explicitly or implicitly when interacting with a notebook for which a controller was _suggested_. When possible, + * the editor _suggests_ a controller that is most likely to be _selected_. + * + * _Note_ that controller selection is persisted (by the controllers {@link NotebookController.id id}) and restored as soon as a + * controller is re-created or as a notebook is {@link workspace.onDidOpenNotebookDocument opened}. */ - //todo@api selected vs associated, jsdoc - readonly onDidChangeNotebookAssociation: Event<{ notebook: NotebookDocument, selected: boolean }>; + readonly onDidChangeSelectedNotebooks: Event<{ notebook: NotebookDocument, selected: boolean }>; /** * A controller can set affinities for specific notebook documents. This allows a controller diff --git a/src/vs/workbench/api/common/extHostNotebookKernels.ts b/src/vs/workbench/api/common/extHostNotebookKernels.ts index 4b4332b305f..b4eb0502372 100644 --- a/src/vs/workbench/api/common/extHostNotebookKernels.ts +++ b/src/vs/workbench/api/common/extHostNotebookKernels.ts @@ -112,7 +112,7 @@ export class ExtHostNotebookKernels implements ExtHostNotebookKernelsShape { const controller: vscode.NotebookController = { get id() { return id; }, get notebookType() { return data.notebookType; }, - onDidChangeNotebookAssociation: onDidChangeSelection.event, + onDidChangeSelectedNotebooks: onDidChangeSelection.event, get label() { return data.label; }, diff --git a/src/vs/workbench/contrib/notebook/test/notebookKernelService.test.ts b/src/vs/workbench/contrib/notebook/test/notebookKernelService.test.ts index 7ad71f59b1d..1d6770c99d7 100644 --- a/src/vs/workbench/contrib/notebook/test/notebookKernelService.test.ts +++ b/src/vs/workbench/contrib/notebook/test/notebookKernelService.test.ts @@ -102,7 +102,7 @@ suite('NotebookKernelService', () => { assert.ok(info.all[1] === kernel); }); - test('onDidChangeNotebookAssociation not fired on initial notebook open #121904', function () { + test('onDidChangeSelectedNotebooks not fired on initial notebook open #121904', function () { const uri = URI.parse('foo:///one'); const jupyter = { uri, viewType: 'jupyter' }; @@ -123,7 +123,7 @@ suite('NotebookKernelService', () => { assert.strictEqual(info.selected === jupyterKernel, true); }); - test('onDidChangeNotebookAssociation not fired on initial notebook open #121904, p2', async function () { + test('onDidChangeSelectedNotebooks not fired on initial notebook open #121904, p2', async function () { const uri = URI.parse('foo:///one'); const jupyter = { uri, viewType: 'jupyter' };