Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/vscode.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/vs/workbench/contrib/notebook/browser/viewParts/notebookEditorWidgetContextKeys.ts')
-rw-r--r--src/vs/workbench/contrib/notebook/browser/viewParts/notebookEditorWidgetContextKeys.ts9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/vs/workbench/contrib/notebook/browser/viewParts/notebookEditorWidgetContextKeys.ts b/src/vs/workbench/contrib/notebook/browser/viewParts/notebookEditorWidgetContextKeys.ts
index a90477db542..3702ac26261 100644
--- a/src/vs/workbench/contrib/notebook/browser/viewParts/notebookEditorWidgetContextKeys.ts
+++ b/src/vs/workbench/contrib/notebook/browser/viewParts/notebookEditorWidgetContextKeys.ts
@@ -6,7 +6,7 @@
import { DisposableStore, dispose, IDisposable } from 'vs/base/common/lifecycle';
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { ICellViewModel, INotebookEditorDelegate, KERNEL_EXTENSIONS } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
-import { NOTEBOOK_CELL_TOOLBAR_LOCATION, NOTEBOOK_HAS_OUTPUTS, NOTEBOOK_HAS_RUNNING_CELL, NOTEBOOK_INTERRUPTIBLE_KERNEL, NOTEBOOK_KERNEL, NOTEBOOK_KERNEL_COUNT, NOTEBOOK_KERNEL_SELECTED, NOTEBOOK_MISSING_KERNEL_EXTENSION, NOTEBOOK_USE_CONSOLIDATED_OUTPUT_BUTTON, NOTEBOOK_VIEW_TYPE } from 'vs/workbench/contrib/notebook/common/notebookContextKeys';
+import { NOTEBOOK_CELL_TOOLBAR_LOCATION, NOTEBOOK_HAS_OUTPUTS, NOTEBOOK_HAS_RUNNING_CELL, NOTEBOOK_INTERRUPTIBLE_KERNEL, NOTEBOOK_KERNEL, NOTEBOOK_KERNEL_COUNT, NOTEBOOK_KERNEL_SELECTED, NOTEBOOK_KERNEL_SOURCE_COUNT, NOTEBOOK_MISSING_KERNEL_EXTENSION, NOTEBOOK_USE_CONSOLIDATED_OUTPUT_BUTTON, NOTEBOOK_VIEW_TYPE } from 'vs/workbench/contrib/notebook/common/notebookContextKeys';
import { INotebookExecutionStateService } from 'vs/workbench/contrib/notebook/common/notebookExecutionStateService';
import { INotebookKernelService } from 'vs/workbench/contrib/notebook/common/notebookKernelService';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
@@ -15,6 +15,7 @@ export class NotebookEditorContextKeys {
private readonly _notebookKernel: IContextKey<string>;
private readonly _notebookKernelCount: IContextKey<number>;
+ private readonly _notebookKernelSourceCount: IContextKey<number>;
private readonly _notebookKernelSelected: IContextKey<boolean>;
private readonly _interruptibleKernel: IContextKey<boolean>;
private readonly _someCellRunning: IContextKey<boolean>;
@@ -44,6 +45,7 @@ export class NotebookEditorContextKeys {
this._hasOutputs = NOTEBOOK_HAS_OUTPUTS.bindTo(contextKeyService);
this._viewType = NOTEBOOK_VIEW_TYPE.bindTo(contextKeyService);
this._missingKernelExtension = NOTEBOOK_MISSING_KERNEL_EXTENSION.bindTo(contextKeyService);
+ this._notebookKernelSourceCount = NOTEBOOK_KERNEL_SOURCE_COUNT.bindTo(contextKeyService);
this._cellToolbarLocation = NOTEBOOK_CELL_TOOLBAR_LOCATION.bindTo(contextKeyService);
this._handleDidChangeModel();
@@ -52,6 +54,7 @@ export class NotebookEditorContextKeys {
this._disposables.add(_editor.onDidChangeModel(this._handleDidChangeModel, this));
this._disposables.add(_notebookKernelService.onDidAddKernel(this._updateKernelContext, this));
this._disposables.add(_notebookKernelService.onDidChangeSelectedNotebooks(this._updateKernelContext, this));
+ this._disposables.add(_notebookKernelService.onDidChangeSourceActions(this._updateKernelContext, this));
this._disposables.add(_editor.notebookOptions.onDidChangeOptions(this._updateForNotebookOptions, this));
this._disposables.add(_extensionService.onDidChangeExtensions(this._updateForInstalledExtension, this));
this._disposables.add(_notebookExecutionStateService.onDidChangeCellExecution(this._updateForCellExecution, this));
@@ -61,6 +64,7 @@ export class NotebookEditorContextKeys {
this._disposables.dispose();
this._viewModelDisposables.dispose();
this._notebookKernelCount.reset();
+ this._notebookKernelSourceCount.reset();
this._interruptibleKernel.reset();
this._someCellRunning.reset();
this._viewType.reset();
@@ -142,12 +146,15 @@ export class NotebookEditorContextKeys {
private _updateKernelContext(): void {
if (!this._editor.hasModel()) {
this._notebookKernelCount.reset();
+ this._notebookKernelSourceCount.reset();
this._interruptibleKernel.reset();
return;
}
const { selected, all } = this._notebookKernelService.getMatchingKernel(this._editor.textModel);
+ const sourceActions = this._notebookKernelService.getSourceActions();
this._notebookKernelCount.set(all.length);
+ this._notebookKernelSourceCount.set(sourceActions.length);
this._interruptibleKernel.set(selected?.implementsInterrupt ?? false);
this._notebookKernelSelected.set(Boolean(selected));
this._notebookKernel.set(selected?.id ?? '');