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 unwanted event handlers #15569

Merged
merged 1 commit into from
Apr 19, 2024
Merged
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
Remove unwanted event handlers
DonJayamanne committed Apr 19, 2024

Verified

This commit was signed with the committer’s verified signature.
sgleizes Stéphane Gleizes
commit 1689cd2b34208c1b06d6ca8d0aac6401cc1df86b
Original file line number Diff line number Diff line change
@@ -2,18 +2,11 @@
// Licensed under the MIT License.

import { inject, injectable } from 'inversify';
import {
NotebookCell,
NotebookCellExecutionState,
NotebookCellExecutionStateChangeEvent,
commands,
notebooks,
window
} from 'vscode';
import { commands, window } from 'vscode';
import { IDataScienceErrorHandler } from '../../../kernels/errors/types';
import { IExtensionSyncActivationService } from '../../../platform/activation/types';
import { IPythonApiProvider, IPythonExtensionChecker } from '../../../platform/api/types';
import { Commands, JupyterNotebookView, Telemetry } from '../../../platform/common/constants';
import { Commands, Telemetry } from '../../../platform/common/constants';
import { IDisposableRegistry } from '../../../platform/common/types';
import { raceTimeout } from '../../../platform/common/utils/async';
import { Common, DataScience } from '../../../platform/common/utils/localize';
@@ -27,8 +20,6 @@ import { sendTelemetryEvent } from '../../../telemetry';
@injectable()
export class InstallPythonControllerCommands implements IExtensionSyncActivationService {
private installedOnceBefore?: boolean;
// WeakSet of executing cells, so they get cleaned up on document close without worrying
private executingCells: WeakSet<NotebookCell> = new WeakSet<NotebookCell>();
constructor(
@inject(IDisposableRegistry) private readonly disposables: IDisposableRegistry,
@inject(IPythonExtensionChecker) private readonly extensionChecker: IPythonExtensionChecker,
@@ -37,9 +28,6 @@ export class InstallPythonControllerCommands implements IExtensionSyncActivation
@inject(IDataScienceErrorHandler) private readonly errorHandler: IDataScienceErrorHandler
) {}
public activate() {
this.disposables.push(
notebooks.onDidChangeNotebookCellExecutionState(this.onDidChangeNotebookCellExecutionState, this)
);
// Register our commands that will handle installing the python extension or python via the kernel picker
this.disposables.push(
commands.registerCommand(
@@ -53,20 +41,6 @@ export class InstallPythonControllerCommands implements IExtensionSyncActivation
);
}

// Track if there are any cells currently executing or pending
private onDidChangeNotebookCellExecutionState(stateEvent: NotebookCellExecutionStateChangeEvent) {
if (stateEvent.cell.notebook.notebookType === JupyterNotebookView) {
if (
stateEvent.state === NotebookCellExecutionState.Pending ||
stateEvent.state === NotebookCellExecutionState.Executing
) {
this.executingCells.add(stateEvent.cell);
} else if (stateEvent.state === NotebookCellExecutionState.Idle) {
this.executingCells.delete(stateEvent.cell);
}
}
}

// This is called via the "install python" command in the kernel picker in the case where
// we have the python extension installed, but 0 valid python kernels / interpreters found
// just pop up a dialog box to prompt the user on how to install python