Skip to content

Commit 68252d3

Browse files
authored
fix: don't leak listener in share contribution (microsoft#236767)
1 parent 13d2a61 commit 68252d3

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/vs/workbench/contrib/share/browser/share.contribution.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import { IProgressService, ProgressLocation } from '../../../../platform/progres
3232
import { ICodeEditorService } from '../../../../editor/browser/services/codeEditorService.js';
3333
import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from '../../../../platform/configuration/common/configurationRegistry.js';
3434
import { workbenchConfigurationNodeBase } from '../../../common/configuration.js';
35-
import { DisposableStore } from '../../../../base/common/lifecycle.js';
35+
import { Disposable, DisposableStore } from '../../../../base/common/lifecycle.js';
3636

3737
const targetMenus = [
3838
MenuId.EditorContextShare,
@@ -44,7 +44,7 @@ const targetMenus = [
4444
MenuId.ExplorerContextShare
4545
];
4646

47-
class ShareWorkbenchContribution {
47+
class ShareWorkbenchContribution extends Disposable {
4848
private static SHARE_ENABLED_SETTING = 'workbench.experimental.share.enabled';
4949

5050
private _disposables: DisposableStore | undefined;
@@ -53,10 +53,12 @@ class ShareWorkbenchContribution {
5353
@IShareService private readonly shareService: IShareService,
5454
@IConfigurationService private readonly configurationService: IConfigurationService
5555
) {
56+
super();
57+
5658
if (this.configurationService.getValue<boolean>(ShareWorkbenchContribution.SHARE_ENABLED_SETTING)) {
5759
this.registerActions();
5860
}
59-
this.configurationService.onDidChangeConfiguration(e => {
61+
this._register(this.configurationService.onDidChangeConfiguration(e => {
6062
if (e.affectsConfiguration(ShareWorkbenchContribution.SHARE_ENABLED_SETTING)) {
6163
const settingValue = this.configurationService.getValue<boolean>(ShareWorkbenchContribution.SHARE_ENABLED_SETTING);
6264
if (settingValue === true && this._disposables === undefined) {
@@ -66,7 +68,12 @@ class ShareWorkbenchContribution {
6668
this._disposables = undefined;
6769
}
6870
}
69-
});
71+
}));
72+
}
73+
74+
override dispose(): void {
75+
super.dispose();
76+
this._disposables?.dispose();
7077
}
7178

7279
private registerActions() {

0 commit comments

Comments
 (0)