Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove usage of controller kind API #13068

Merged
merged 1 commit into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2034,7 +2034,6 @@
]
},
"enabledApiProposals": [
"notebookControllerKind",
"notebookDeprecated",
"notebookMessaging",
"notebookMime",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { IJupyterServerUriStorage } from '../../../kernels/jupyter/types';
import { DataScience } from '../../../platform/common/utils/localize';
import { disposeAllDisposables } from '../../../platform/common/helpers';
import { traceVerbose } from '../../../platform/logging';
import { ConnectionDisplayDataProvider } from '../connectionDisplayData';

export function groupBy<T>(data: ReadonlyArray<T>, compare: (a: T, b: T) => number): T[][] {
const result: T[][] = [];
Expand Down Expand Up @@ -66,7 +67,8 @@ export class ServerConnectionControllerCommands implements IExtensionSyncActivat
@inject(IControllerRegistration) private readonly controllerRegistration: IControllerRegistration,
@inject(IVSCodeNotebook) private readonly notebooks: IVSCodeNotebook,
@inject(IJupyterServerUriStorage) private readonly serverUriStorage: IJupyterServerUriStorage,
@inject(IFeaturesManager) private readonly featuresManager: IFeaturesManager
@inject(IFeaturesManager) private readonly featuresManager: IFeaturesManager,
@inject(IFeaturesManager) private readonly displayDataProvider: ConnectionDisplayDataProvider
) {
this.showingLocalOrWebEmptyContext = new ContextKey('jupyter.showingLocalOrWebEmpty', this.commandManager);
}
Expand Down Expand Up @@ -193,12 +195,15 @@ export class ServerConnectionControllerCommands implements IExtensionSyncActivat

// Then group them by kind
const kernelsPerCategory = groupBy(picks, (a, b) =>
compareIgnoreCase(a.controller.controller.kind || 'z', b.controller.controller.kind || 'z')
compareIgnoreCase(
this.displayDataProvider.getDisplayData(a.controller.connection).category || 'z',
this.displayDataProvider.getDisplayData(b.controller.connection).category || 'z'
)
);
const kindIndexes = new Map<string, number>();
const quickPickItems: (QuickPickItem | ControllerQuickPick)[] = [];
kernelsPerCategory.forEach((items) => {
const kind = items[0].controller.controller.kind || 'Other';
const kind = this.displayDataProvider.getDisplayData(items[0].controller.connection).category || 'Other';
quickPickItems.push({
kind: QuickPickItemKind.Separator,
label: kind
Expand All @@ -223,7 +228,7 @@ export class ServerConnectionControllerCommands implements IExtensionSyncActivat
};

// Stick into the list at the right place
const kind = e.controller.kind || 'Other';
const kind = this.displayDataProvider.getDisplayData(e.connection).category || 'Other';
const index = kindIndexes.get(kind) || -1;
if (index < 0) {
quickPickItems.push({
Expand Down
1 change: 0 additions & 1 deletion src/notebooks/controllers/vscodeNotebookController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,6 @@ export class VSCodeNotebookController implements Disposable, IVSCodeNotebookCont
? `${displayData.description} (${displayData.serverDisplayName})`
: displayData.serverDisplayName;
}
this.controller.kind = displayData.category;
}
// Handle the execution of notebook cell
@traceDecoratorVerbose('VSCodeNotebookController::handleExecution', TraceOptions.BeforeCall)
Expand Down