提交 87d7c6dd 编写于 作者: A Alex Ross

Listener leak when scrolling PULL REQUESTS view

Fixes #107801
上级 60f19d59
......@@ -328,7 +328,7 @@ export abstract class AbstractContextKeyService implements IContextKeyService {
public abstract getContextValuesContainer(contextId: number): Context;
public abstract createChildContext(parentContextId?: number): number;
public abstract disposeContext(contextId: number): void;
public abstract updateParent(parentContextKeyService: IContextKeyService): void;
public abstract updateParent(parentContextKeyService?: IContextKeyService): void;
}
export class ContextKeyService extends AbstractContextKeyService implements IContextKeyService {
......@@ -423,6 +423,7 @@ class ScopedContextKeyService extends AbstractContextKeyService {
public dispose(): void {
this._isDisposed = true;
this._parent.disposeContext(this._myContextId);
this._parentChangeListener?.dispose();
if (this._domNode) {
this._domNode.removeAttribute(KEYBINDING_CONTEXT_ATTR);
this._domNode = undefined;
......@@ -454,7 +455,11 @@ class ScopedContextKeyService extends AbstractContextKeyService {
this._parent.disposeContext(contextId);
}
public updateParent(parentContextKeyService: AbstractContextKeyService): void {
public updateParent(parentContextKeyService?: AbstractContextKeyService): void {
if (!parentContextKeyService) {
this._parentChangeListener?.dispose();
return;
}
const thisContainer = this._parent.getContextValuesContainer(this._myContextId);
const oldAllValues = thisContainer.collectAllValues();
this._parent = parentContextKeyService;
......
......@@ -1139,7 +1139,7 @@ export interface IContextKeyService {
createScoped(target?: IContextKeyServiceTarget): IContextKeyService;
getContext(target: IContextKeyServiceTarget | null): IContext;
updateParent(parentContextKeyService: IContextKeyService): void;
updateParent(parentContextKeyService?: IContextKeyService): void;
}
export const SET_CONTEXT_COMMAND_ID = 'setContext';
......@@ -1027,7 +1027,9 @@ class TreeMenus extends Disposable implements IDisposable {
createAndFillInContextMenuActions(menu, { shouldForwardArgs: true }, result, this.contextMenuService, g => /^inline/.test(g));
menu.dispose();
// When called without a parameter, updateParent will dispose the parent change listener.
// We cannot call dispose on the contextKeyService because it will break submenus.
contextKeyService.updateParent();
return result;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册