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

Do not add self to disposables #15552

Merged
merged 1 commit into from
Apr 17, 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
26 changes: 11 additions & 15 deletions src/standalone/import-export/importTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import { ResourceTypeTelemetryProperty, onDidChangeTelemetryEnablement, sendTelemetryEvent } from '../../telemetry';
import { IExtensionSyncActivationService } from '../../platform/activation/types';
import { isCI, isTestExecution, JupyterNotebookView, PYTHON_LANGUAGE } from '../../platform/common/constants';
import { dispose } from '../../platform/common/utils/lifecycle';
import { DisposableStore, dispose } from '../../platform/common/utils/lifecycle';
import { IDisposable, IDisposableRegistry } from '../../platform/common/types';
import { noop } from '../../platform/common/utils/misc';
import { EventName } from '../../platform/telemetry/constants';
Expand Down Expand Up @@ -63,23 +63,20 @@ export interface IImportTracker {}
@injectable()
export class ImportTracker implements IExtensionSyncActivationService, IDisposable {
private pendingChecks = new ResourceMap<NodeJS.Timer | number>();
private disposables: IDisposable[] = [];
private disposables = new DisposableStore();
private sentMatches = new Set<string>();
private isTelemetryDisabled: boolean;
constructor(@inject(IDisposableRegistry) disposables: IDisposableRegistry, delay = 1_000) {
disposables.push(this);
disposables.push(this.disposables);
this.isTelemetryDisabled = isTelemetryDisabled();
workspace.onDidOpenNotebookDocument(
(t) => this.onOpenedOrClosedNotebookDocument(t, 'onOpenCloseOrSave'),
this.disposables
this.disposables.add(
workspace.onDidOpenNotebookDocument((t) => this.onOpenedOrClosedNotebookDocument(t, 'onOpenCloseOrSave'))
);
workspace.onDidCloseNotebookDocument(
(t) => this.onOpenedOrClosedNotebookDocument(t, 'onOpenCloseOrSave'),
this.disposables
this.disposables.add(
workspace.onDidCloseNotebookDocument((t) => this.onOpenedOrClosedNotebookDocument(t, 'onOpenCloseOrSave'))
);
workspace.onDidSaveNotebookDocument(
(t) => this.onOpenedOrClosedNotebookDocument(t, 'onOpenCloseOrSave'),
this.disposables
this.disposables.add(
workspace.onDidSaveNotebookDocument((t) => this.onOpenedOrClosedNotebookDocument(t, 'onOpenCloseOrSave'))
);
const delayer = new Delayer<void>(delay);
notebooks.onDidChangeNotebookCellExecutionState(
Expand All @@ -93,11 +90,10 @@ export class ImportTracker implements IExtensionSyncActivationService, IDisposab
this,
disposables
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DonJayamanne should it be this.disposables?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that shouldn't matter, & it shouldn't cause a recursive
But needs to be changed to be consistent,

);
this.disposables.push(
this.disposables.add(
onDidChangeTelemetryEnablement((enabled) => {
this.isTelemetryDisabled = enabled;
}),
this
})
);
}

Expand Down
Loading