From f81c4784b6febce3931eb24a17737395026f83e7 Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Fri, 24 Jun 2022 09:22:54 -0700 Subject: Delete "set kernel as default" button which did not really work (#153053) For #151158 --- .../contrib/editorStatusBar/editorStatusBar.ts | 33 ++++++++-------------- .../notebook/browser/notebookKernelServiceImpl.ts | 24 ++-------------- .../notebook/common/notebookKernelService.ts | 7 ----- 3 files changed, 13 insertions(+), 51 deletions(-) (limited to 'src/vs/workbench/contrib') diff --git a/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.ts b/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.ts index 6b7e8cc0cf7..285dae8f94e 100644 --- a/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.ts +++ b/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.ts @@ -4,9 +4,12 @@ *--------------------------------------------------------------------------------------------*/ import { groupBy } from 'vs/base/common/arrays'; +import { CancellationToken } from 'vs/base/common/cancellation'; +import { Codicon } from 'vs/base/common/codicons'; import { Disposable, DisposableStore, IDisposable, MutableDisposable } from 'vs/base/common/lifecycle'; import { Schemas } from 'vs/base/common/network'; import { compareIgnoreCase, uppercaseFirstLetter } from 'vs/base/common/strings'; +import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeatures'; import * as nls from 'vs/nls'; import { Action2, MenuId, registerAction2 } from 'vs/platform/actions/common/actions'; import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; @@ -14,31 +17,27 @@ import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions'; import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; import { ILabelService } from 'vs/platform/label/common/label'; import { ILogService } from 'vs/platform/log/common/log'; -import { IQuickInputButton, IQuickInputService, IQuickPickItem, QuickPickInput } from 'vs/platform/quickinput/common/quickInput'; +import { IProductService } from 'vs/platform/product/common/productService'; +import { ProgressLocation } from 'vs/platform/progress/common/progress'; +import { IQuickInputService, IQuickPickItem, QuickPickInput } from 'vs/platform/quickinput/common/quickInput'; import { Registry } from 'vs/platform/registry/common/platform'; -import { ThemeIcon } from 'vs/platform/theme/common/themeService'; import { Extensions as WorkbenchExtensions, IWorkbenchContribution, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions'; import { ViewContainerLocation } from 'vs/workbench/common/views'; import { IExtensionsViewPaneContainer, IExtensionsWorkbenchService, VIEWLET_ID as EXTENSION_VIEWLET_ID } from 'vs/workbench/contrib/extensions/common/extensions'; import { CENTER_ACTIVE_CELL } from 'vs/workbench/contrib/notebook/browser/contrib/navigation/arrow'; import { NOTEBOOK_ACTIONS_CATEGORY, SELECT_KERNEL_ID } from 'vs/workbench/contrib/notebook/browser/controller/coreActions'; -import { NOTEBOOK_MISSING_KERNEL_EXTENSION, NOTEBOOK_IS_ACTIVE_EDITOR, NOTEBOOK_KERNEL_COUNT, NOTEBOOK_KERNEL_SOURCE_COUNT } from 'vs/workbench/contrib/notebook/common/notebookContextKeys'; import { getNotebookEditorFromEditorPane, INotebookEditor, INotebookExtensionRecommendation, KERNEL_RECOMMENDATIONS } from 'vs/workbench/contrib/notebook/browser/notebookBrowser'; import { NotebookEditorWidget } from 'vs/workbench/contrib/notebook/browser/notebookEditorWidget'; -import { configureKernelIcon, selectKernelIcon } from 'vs/workbench/contrib/notebook/browser/notebookIcons'; +import { selectKernelIcon } from 'vs/workbench/contrib/notebook/browser/notebookIcons'; import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel'; import { NotebookCellsChangeType } from 'vs/workbench/contrib/notebook/common/notebookCommon'; +import { NOTEBOOK_IS_ACTIVE_EDITOR, NOTEBOOK_KERNEL_COUNT, NOTEBOOK_KERNEL_SOURCE_COUNT, NOTEBOOK_MISSING_KERNEL_EXTENSION } from 'vs/workbench/contrib/notebook/common/notebookContextKeys'; import { INotebookKernel, INotebookKernelService, ISourceAction } from 'vs/workbench/contrib/notebook/common/notebookKernelService'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; +import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle'; import { IPaneCompositePartService } from 'vs/workbench/services/panecomposite/browser/panecomposite'; import { IStatusbarEntry, IStatusbarEntryAccessor, IStatusbarService, StatusbarAlignment } from 'vs/workbench/services/statusbar/browser/statusbar'; -import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeatures'; -import { CancellationToken } from 'vs/base/common/cancellation'; -import { ProgressLocation } from 'vs/platform/progress/common/progress'; -import { IProductService } from 'vs/platform/product/common/productService'; -import { Codicon } from 'vs/base/common/codicons'; -import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; registerAction2(class extends Action2 { constructor() { @@ -173,18 +172,13 @@ registerAction2(class extends Action2 { type KernelPick = IQuickPickItem & { kernel: INotebookKernel }; type SourcePick = IQuickPickItem & { action: ISourceAction }; - const configButton: IQuickInputButton = { - iconClass: ThemeIcon.asClassName(configureKernelIcon), - tooltip: nls.localize('notebook.promptKernel.setDefaultTooltip', "Set as default for '{0}' notebooks", editor.textModel.viewType) - }; function toQuickPick(kernel: INotebookKernel) { const res = { kernel, picked: kernel.id === selected?.id, label: kernel.label, description: kernel.description, - detail: kernel.detail, - buttons: [configButton] + detail: kernel.detail }; if (kernel.id === selected?.id) { if (!res.description) { @@ -262,12 +256,7 @@ registerAction2(class extends Action2 { const pick = await quickInputService.pick(quickPickItems, { placeHolder: selected ? nls.localize('prompt.placeholder.change', "Change kernel for '{0}'", labelService.getUriLabel(notebook.uri, { relative: true })) - : nls.localize('prompt.placeholder.select', "Select kernel for '{0}'", labelService.getUriLabel(notebook.uri, { relative: true })), - onDidTriggerItemButton: (context) => { - if ('kernel' in context.item) { - notebookKernelService.selectKernelForNotebookType(context.item.kernel, notebook.viewType); - } - } + : nls.localize('prompt.placeholder.select', "Select kernel for '{0}'", labelService.getUriLabel(notebook.uri, { relative: true })) }); if (pick) { diff --git a/src/vs/workbench/contrib/notebook/browser/notebookKernelServiceImpl.ts b/src/vs/workbench/contrib/notebook/browser/notebookKernelServiceImpl.ts index 07f867da659..a069a226017 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebookKernelServiceImpl.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebookKernelServiceImpl.ts @@ -80,7 +80,6 @@ export class NotebookKernelService extends Disposable implements INotebookKernel private readonly _kernels = new Map(); - private readonly _typeBindings = new LRUCache(100, 0.7); private readonly _notebookBindings = new LRUCache(1000, 0.7); private readonly _onDidChangeNotebookKernelBinding = this._register(new Emitter()); @@ -98,7 +97,6 @@ export class NotebookKernelService extends Disposable implements INotebookKernel readonly onDidChangeSourceActions: Event = this._onDidChangeSourceActions.event; private static _storageNotebookBinding = 'notebook.controller2NotebookBindings'; - private static _storageTypeBinding = 'notebook.controller2TypeBindings'; constructor( @@ -130,12 +128,6 @@ export class NotebookKernelService extends Disposable implements INotebookKernel } catch { // ignore } - try { - const data = JSON.parse(this._storageService.get(NotebookKernelService._storageTypeBinding, StorageScope.PROFILE, '[]')); - this._typeBindings.fromJSON(data); - } catch { - // ignore - } } private _initSourceActions() { @@ -174,7 +166,6 @@ export class NotebookKernelService extends Disposable implements INotebookKernel this._persistSoonHandle?.dispose(); this._persistSoonHandle = runWhenIdle(() => { this._storageService.store(NotebookKernelService._storageNotebookBinding, JSON.stringify(this._notebookBindings), StorageScope.WORKSPACE, StorageTarget.MACHINE); - this._storageService.store(NotebookKernelService._storageTypeBinding, JSON.stringify(this._typeBindings), StorageScope.PROFILE, StorageTarget.USER); }, 100); } @@ -234,7 +225,7 @@ export class NotebookKernelService extends Disposable implements INotebookKernel getMatchingKernel(notebook: INotebookTextModelLike): INotebookKernelMatchResult { // all applicable kernels - const kernels: { kernel: INotebookKernel; instanceAffinity: number; typeAffinity: number; score: number }[] = []; + const kernels: { kernel: INotebookKernel; instanceAffinity: number; score: number }[] = []; for (const info of this._kernels.values()) { const score = NotebookKernelService._score(info.kernel, notebook); if (score) { @@ -242,13 +233,12 @@ export class NotebookKernelService extends Disposable implements INotebookKernel score, kernel: info.kernel, instanceAffinity: info.notebookPriorities.get(notebook.uri) ?? 1 /* vscode.NotebookControllerPriority.Default */, - typeAffinity: this._typeBindings.get(info.kernel.viewType) === info.kernel.id ? 1 : 0 }); } } kernels - .sort((a, b) => b.instanceAffinity - a.instanceAffinity || b.typeAffinity - a.typeAffinity || a.score - b.score || a.kernel.label.localeCompare(b.kernel.label)); + .sort((a, b) => b.instanceAffinity - a.instanceAffinity || a.score - b.score || a.kernel.label.localeCompare(b.kernel.label)); const all = kernels.map(obj => obj.kernel); // bound kernel @@ -275,16 +265,6 @@ export class NotebookKernelService extends Disposable implements INotebookKernel return info.all.length === 1 ? info.all[0] : undefined; } - // default kernel for notebookType - selectKernelForNotebookType(kernel: INotebookKernel, typeId: string): void { - const existing = this._typeBindings.get(typeId); - if (existing !== kernel.id) { - this._typeBindings.set(typeId, kernel.id); - this._persistMementos(); - this._onDidChangeNotebookAffinity.fire(); - } - } - // a notebook has one kernel, a kernel has N notebooks // notebook <-1----N-> kernel selectKernelForNotebook(kernel: INotebookKernel | undefined, notebook: INotebookTextModelLike): void { diff --git a/src/vs/workbench/contrib/notebook/common/notebookKernelService.ts b/src/vs/workbench/contrib/notebook/common/notebookKernelService.ts index 2ab657faf5b..756377bdd86 100644 --- a/src/vs/workbench/contrib/notebook/common/notebookKernelService.ts +++ b/src/vs/workbench/contrib/notebook/common/notebookKernelService.ts @@ -102,13 +102,6 @@ export interface INotebookKernelService { */ preselectKernelForNotebook(kernel: INotebookKernel, notebook: INotebookTextModelLike): void; - /** - * Bind a notebook type to a kernel. - * @param viewType - * @param kernel - */ - selectKernelForNotebookType(kernel: INotebookKernel, viewType: string): void; - /** * Set a perference of a kernel for a certain notebook. Higher values win, `undefined` removes the preference */ -- cgit v1.2.3