From e3476ac18652465344daae8d98a5510c34cc93c4 Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Mon, 26 Apr 2021 21:01:35 -0700 Subject: [PATCH 1/6] API TODO --- src/vs/vscode.proposed.d.ts | 13 ++++++------- src/vs/workbench/api/common/extHostTypes.ts | 12 ++++++------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index 8c646fe074f..875a07d8214 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -1869,14 +1869,13 @@ declare module 'vscode' { Right = 2 } - // todo@API remove readonlyness. export class NotebookCellStatusBarItem { - readonly text: string; - readonly alignment: NotebookCellStatusBarAlignment; - readonly command?: string | Command; - readonly tooltip?: string; - readonly priority?: number; - readonly accessibilityInformation?: AccessibilityInformation; + text: string; + alignment: NotebookCellStatusBarAlignment; + command?: string | Command; + tooltip?: string; + priority?: number; + accessibilityInformation?: AccessibilityInformation; constructor(text: string, alignment: NotebookCellStatusBarAlignment, command?: string | Command, tooltip?: string, priority?: number, accessibilityInformation?: AccessibilityInformation); } diff --git a/src/vs/workbench/api/common/extHostTypes.ts b/src/vs/workbench/api/common/extHostTypes.ts index b25ed3e01a8..85e8d64cc59 100644 --- a/src/vs/workbench/api/common/extHostTypes.ts +++ b/src/vs/workbench/api/common/extHostTypes.ts @@ -3155,12 +3155,12 @@ export enum NotebookEditorRevealType { export class NotebookCellStatusBarItem { constructor( - readonly text: string, - readonly alignment: NotebookCellStatusBarAlignment, - readonly command?: string | vscode.Command, - readonly tooltip?: string, - readonly priority?: number, - readonly accessibilityInformation?: vscode.AccessibilityInformation) { } + public text: string, + public alignment: NotebookCellStatusBarAlignment, + public command?: string | vscode.Command, + public tooltip?: string, + public priority?: number, + public accessibilityInformation?: vscode.AccessibilityInformation) { } } From f88202aa46f5f7131294282a940db8fed27d4aa7 Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Mon, 26 Apr 2021 21:35:56 -0700 Subject: [PATCH 2/6] Fix missing cell execution icon --- .../contrib/statusBar/executionStatusBarItemController.ts | 7 +++---- src/vs/workbench/contrib/notebook/common/notebookCommon.ts | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/vs/workbench/contrib/notebook/browser/contrib/statusBar/executionStatusBarItemController.ts b/src/vs/workbench/contrib/notebook/browser/contrib/statusBar/executionStatusBarItemController.ts index a047dde47df..06ce2d7cc98 100644 --- a/src/vs/workbench/contrib/notebook/browser/contrib/statusBar/executionStatusBarItemController.ts +++ b/src/vs/workbench/contrib/notebook/browser/contrib/statusBar/executionStatusBarItemController.ts @@ -7,12 +7,11 @@ import { RunOnceScheduler } from 'vs/base/common/async'; import { Event } from 'vs/base/common/event'; import { Disposable, dispose, IDisposable } from 'vs/base/common/lifecycle'; import { localize } from 'vs/nls'; -import { themeColorFromId, ThemeIcon } from 'vs/platform/theme/common/themeService'; +import { themeColorFromId } from 'vs/platform/theme/common/themeService'; import { ICellVisibilityChangeEvent, NotebookVisibleCellObserver } from 'vs/workbench/contrib/notebook/browser/contrib/statusBar/notebookVisibleCellObserver'; import { ICellViewModel, INotebookEditor, INotebookEditorContribution } from 'vs/workbench/contrib/notebook/browser/notebookBrowser'; import { registerNotebookContribution } from 'vs/workbench/contrib/notebook/browser/notebookEditorExtensions'; import { cellStatusIconError, cellStatusIconSuccess } from 'vs/workbench/contrib/notebook/browser/notebookEditorWidget'; -import { executingStateIcon, pendingStateIcon } from 'vs/workbench/contrib/notebook/browser/notebookIcons'; import { NotebookViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel'; import { CellStatusbarAlignment, INotebookCellStatusBarItem, NotebookCellExecutionState } from 'vs/workbench/contrib/notebook/common/notebookCommon'; @@ -138,14 +137,14 @@ class ExecutionStateCellStatusBarHelper extends Disposable { }; } else if (runState === NotebookCellExecutionState.Pending) { return { - icon: pendingStateIcon, + text: '$(notebook-state-pending)', tooltip: localize('notebook.cell.status.pending', "Pending"), alignment: CellStatusbarAlignment.Left, priority: Number.MAX_SAFE_INTEGER }; } else if (runState === NotebookCellExecutionState.Executing) { return { - icon: ThemeIcon.modify(executingStateIcon, 'spin'), + text: '$(notebook-state-executing~spin)', tooltip: localize('notebook.cell.status.executing', "Executing"), alignment: CellStatusbarAlignment.Left, priority: Number.MAX_SAFE_INTEGER diff --git a/src/vs/workbench/contrib/notebook/common/notebookCommon.ts b/src/vs/workbench/contrib/notebook/common/notebookCommon.ts index ae910076cd4..dec4496d3a2 100644 --- a/src/vs/workbench/contrib/notebook/common/notebookCommon.ts +++ b/src/vs/workbench/contrib/notebook/common/notebookCommon.ts @@ -810,7 +810,7 @@ export interface INotebookDiffResult { export interface INotebookCellStatusBarItem { readonly alignment: CellStatusbarAlignment; readonly priority?: number; - readonly text?: string; + readonly text: string; readonly color?: string | ThemeColor; readonly backgroundColor?: string | ThemeColor; readonly tooltip?: string; From 912e8aff9c498ff56a18f237b98a83f59f5f8e3b Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Tue, 27 Apr 2021 17:23:48 +0200 Subject: [PATCH 3/6] fix https://github.com/microsoft/vscode/issues/122328 --- .../contrib/notebook/common/model/notebookTextModel.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts b/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts index 20ccbce693f..188d293c445 100644 --- a/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts +++ b/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts @@ -18,7 +18,7 @@ import { IModelService } from 'vs/editor/common/services/modelService'; import { Schemas } from 'vs/base/common/network'; import { isEqual } from 'vs/base/common/resources'; import { IModeService } from 'vs/editor/common/services/modeService'; -import { ITextModel } from 'vs/editor/common/model'; +import { ITextBuffer, ITextModel } from 'vs/editor/common/model'; import { TextModel } from 'vs/editor/common/model/textModel'; @@ -513,6 +513,9 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel if (textModel && textModel instanceof TextModel) { cell.textModel = textModel; cell.language = cellDto.language; + if (!cell.textModel.equalsTextBuffer(cell.textBuffer as ITextBuffer)) { + cell.textModel.setValue(cellDto.source); + } } const dirtyStateListener = cell.onDidChangeContent(() => { this._increaseVersionIdForCellContentChange(); From 232b10fb540ae39a2e6b232922ee643a0ee5085b Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Wed, 28 Apr 2021 11:23:02 +0200 Subject: [PATCH 4/6] more jsdoc for supportedLanguages, fixes https://github.com/microsoft/vscode/issues/122372 --- src/vs/vscode.proposed.d.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index c7439d5d232..cafd298c8d3 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -1565,7 +1565,18 @@ declare module 'vscode' { /** * An array of language identifiers that are supported by this - * controller. When falsy all languages are supported. + * controller. Any language identifier from [`getLanguages`](#languages.getLanguages) + * is possible. When falsy all languages are supported. + * + * Samples: + * ```js + * // support JavaScript and TypeScript + * myController.supportedLanguages = ['javascript', 'typescript'] + * + * // support all languages + * myController.supportedLanguages = undefined; // falsy + * myController.supportedLanguages = []; // falsy + * ``` */ supportedLanguages?: string[]; From 5688d75ef95fce42ede3c0212670e9fb0ed67290 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Wed, 28 Apr 2021 11:27:41 +0200 Subject: [PATCH 5/6] update jsdoc for NotebookController#viewType --- src/vs/vscode.proposed.d.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index cafd298c8d3..50c3f1144ca 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -1554,12 +1554,7 @@ declare module 'vscode' { readonly id: string; /** - * The selector allows to narrow down on specific notebook types or - * instances. - * - * For instance `{ viewType: 'notebook.test' }` selects all notebook - * documents of the type `notebook.test`, whereas `{ pattern: '/my/file/test.nb' }` - * selects only the notebook with the path `/my/file/test.nb`. + * The notebook view type this controller is for. */ readonly viewType: string; @@ -1685,7 +1680,7 @@ declare module 'vscode' { * Creates a new notebook controller. * * @param id Extension-unique identifier of the controller - * @param selector A notebook selector to narrow down notebook type or path + * @param viewType A notebook type for which this controller is for. * @param label The label of the controller * @param handler * @param preloads From 8420e94d8d24d884a0c45f844604a026245f515a Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Wed, 28 Apr 2021 11:32:29 +0200 Subject: [PATCH 6/6] fix https://github.com/microsoft/vscode/issues/122270 --- .../contrib/notebook/test/notebookEditorKernelManager.test.ts | 2 +- .../contrib/notebook/test/notebookKernelService.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/contrib/notebook/test/notebookEditorKernelManager.test.ts b/src/vs/workbench/contrib/notebook/test/notebookEditorKernelManager.test.ts index b1348c26f89..77acc75de28 100644 --- a/src/vs/workbench/contrib/notebook/test/notebookEditorKernelManager.test.ts +++ b/src/vs/workbench/contrib/notebook/test/notebookEditorKernelManager.test.ts @@ -59,7 +59,7 @@ suite('NotebookEditorKernelManager', () => { await withTestNotebook( [], async (viewModel) => { - const kernelManager = instantiationService.createInstance(NotebookEditorKernelManager, { activeKernel: undefined, viewModel }); + const kernelManager = instantiationService.createInstance(NotebookEditorKernelManager); const cell = viewModel.createCell(1, 'var c = 3', 'javascript', CellKind.Code, {}, [], true); await assertThrowsAsync(async () => await kernelManager.executeNotebookCell(cell)); diff --git a/src/vs/workbench/contrib/notebook/test/notebookKernelService.test.ts b/src/vs/workbench/contrib/notebook/test/notebookKernelService.test.ts index fc9164586be..bcaaf057a75 100644 --- a/src/vs/workbench/contrib/notebook/test/notebookKernelService.test.ts +++ b/src/vs/workbench/contrib/notebook/test/notebookKernelService.test.ts @@ -140,7 +140,7 @@ suite('NotebookKernelService', () => { { // open as jupyter -> bind event const p1 = Event.toPromise(kernelService.onDidChangeNotebookKernelBinding); - const d1 = instantiationService.createInstance(NotebookTextModel, jupyter.viewType, jupyter.uri, [], {}); + const d1 = instantiationService.createInstance(NotebookTextModel, jupyter.viewType, jupyter.uri, [], {}, {}); onDidAddNotebookDocument.fire(d1); const event = await p1; assert.strictEqual(event.newKernel, jupyterKernel.id); @@ -148,7 +148,7 @@ suite('NotebookKernelService', () => { { // RE-open as dotnet -> bind event const p2 = Event.toPromise(kernelService.onDidChangeNotebookKernelBinding); - const d2 = instantiationService.createInstance(NotebookTextModel, dotnet.viewType, dotnet.uri, [], {}); + const d2 = instantiationService.createInstance(NotebookTextModel, dotnet.viewType, dotnet.uri, [], {}, {}); onDidAddNotebookDocument.fire(d2); const event2 = await p2; assert.strictEqual(event2.newKernel, dotnetKernel.id);