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

fix: don't leak listener in share contribution #236767

Merged
merged 1 commit into from
Dec 21, 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
15 changes: 11 additions & 4 deletions src/vs/workbench/contrib/share/browser/share.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { IProgressService, ProgressLocation } from '../../../../platform/progres
import { ICodeEditorService } from '../../../../editor/browser/services/codeEditorService.js';
import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from '../../../../platform/configuration/common/configurationRegistry.js';
import { workbenchConfigurationNodeBase } from '../../../common/configuration.js';
import { DisposableStore } from '../../../../base/common/lifecycle.js';
import { Disposable, DisposableStore } from '../../../../base/common/lifecycle.js';

const targetMenus = [
MenuId.EditorContextShare,
Expand All @@ -44,7 +44,7 @@ const targetMenus = [
MenuId.ExplorerContextShare
];

class ShareWorkbenchContribution {
class ShareWorkbenchContribution extends Disposable {
private static SHARE_ENABLED_SETTING = 'workbench.experimental.share.enabled';

private _disposables: DisposableStore | undefined;
Expand All @@ -53,10 +53,12 @@ class ShareWorkbenchContribution {
@IShareService private readonly shareService: IShareService,
@IConfigurationService private readonly configurationService: IConfigurationService
) {
super();

if (this.configurationService.getValue<boolean>(ShareWorkbenchContribution.SHARE_ENABLED_SETTING)) {
this.registerActions();
}
this.configurationService.onDidChangeConfiguration(e => {
this._register(this.configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration(ShareWorkbenchContribution.SHARE_ENABLED_SETTING)) {
const settingValue = this.configurationService.getValue<boolean>(ShareWorkbenchContribution.SHARE_ENABLED_SETTING);
if (settingValue === true && this._disposables === undefined) {
Expand All @@ -66,7 +68,12 @@ class ShareWorkbenchContribution {
this._disposables = undefined;
}
}
});
}));
}

override dispose(): void {
super.dispose();
this._disposables?.dispose();
}

private registerActions() {
Expand Down
Loading