Skip to content

Commit

Permalink
Do not add self to disposables (#15552)
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne authored Apr 17, 2024
1 parent a9cfb97 commit cc4db4d
Showing 1 changed file with 11 additions and 15 deletions.
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
);
this.disposables.push(
this.disposables.add(
onDidChangeTelemetryEnablement((enabled) => {
this.isTelemetryDisabled = enabled;
}),
this
})
);
}

Expand Down

0 comments on commit cc4db4d

Please sign in to comment.