SCM - use MutableDisposable in SCMInputWidgetToolbar (#221173)

This commit is contained in:
Ladislau Szomoru 2024-07-08 19:45:05 +02:00 committed by GitHub
parent 1e6b49798d
commit e86f5306cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2179,7 +2179,7 @@ class SCMInputWidgetToolbar extends WorkbenchToolBar {
private _onDidChange = new Emitter<void>();
readonly onDidChange: Event<void> = this._onDidChange.event;
private readonly repositoryDisposables = new DisposableStore();
private readonly _disposables = this._register(new MutableDisposable<DisposableStore>());
constructor(
container: HTMLElement,
@ -2207,7 +2207,7 @@ class SCMInputWidgetToolbar extends WorkbenchToolBar {
}
public setInput(input: ISCMInput): void {
this.repositoryDisposables.clear();
this._disposables.value = new DisposableStore();
const contextKeyService = this.contextKeyService.createOverlay([
['scmProvider', input.repository.provider.contextValue],
@ -2215,7 +2215,7 @@ class SCMInputWidgetToolbar extends WorkbenchToolBar {
['scmProviderHasRootUri', !!input.repository.provider.rootUri]
]);
const menu = this.repositoryDisposables.add(this.menuService.createMenu(MenuId.SCMInputBox, contextKeyService, { emitEventsForSubmenuChanges: true }));
const menu = this._disposables.value.add(this.menuService.createMenu(MenuId.SCMInputBox, contextKeyService, { emitEventsForSubmenuChanges: true }));
const isEnabled = (): boolean => {
return input.repository.provider.groups.some(g => g.resources.length > 0);
@ -2245,18 +2245,18 @@ class SCMInputWidgetToolbar extends WorkbenchToolBar {
this._onDidChange.fire();
};
this.repositoryDisposables.add(menu.onDidChange(() => updateToolbar()));
this.repositoryDisposables.add(input.repository.provider.onDidChangeResources(() => updateToolbar()));
this.repositoryDisposables.add(this.storageService.onDidChangeValue(StorageScope.PROFILE, SCMInputWidgetStorageKey.LastActionId, this.repositoryDisposables)(() => updateToolbar()));
this._disposables.value.add(menu.onDidChange(() => updateToolbar()));
this._disposables.value.add(input.repository.provider.onDidChangeResources(() => updateToolbar()));
this._disposables.value.add(this.storageService.onDidChangeValue(StorageScope.PROFILE, SCMInputWidgetStorageKey.LastActionId, this._disposables.value)(() => updateToolbar()));
this.actionRunner = new SCMInputWidgetActionRunner(input, this.storageService);
this.repositoryDisposables.add(this.actionRunner.onWillRun(e => {
this._disposables.value.add(this.actionRunner.onWillRun(e => {
if ((this.actionRunner as SCMInputWidgetActionRunner).runningActions.size === 0) {
super.setActions([this._cancelAction], []);
this._onDidChange.fire();
}
}));
this.repositoryDisposables.add(this.actionRunner.onDidRun(e => {
this._disposables.value.add(this.actionRunner.onDidRun(e => {
if ((this.actionRunner as SCMInputWidgetActionRunner).runningActions.size === 0) {
updateToolbar();
}
@ -2264,11 +2264,6 @@ class SCMInputWidgetToolbar extends WorkbenchToolBar {
updateToolbar();
}
override dispose(): void {
this.repositoryDisposables.dispose();
super.dispose();
}
}
class SCMInputWidgetEditorOptions {