mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
Merge pull request #124741 from jeanp413/fix-124735
Fixes listener leak while updating terminal pane actions
This commit is contained in:
commit
cd501b2e5b
|
@ -10,7 +10,6 @@ import { IAction } from 'vs/base/common/actions';
|
|||
import * as DOM from 'vs/base/browser/dom';
|
||||
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { KeyCode } from 'vs/base/common/keyCodes';
|
||||
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { MenuItemAction } from 'vs/platform/actions/common/actions';
|
||||
import { MenuEntryActionViewItem } from 'vs/platform/actions/browser/menuEntryActionViewItem';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
|
@ -21,7 +20,6 @@ export class DropdownWithPrimaryActionViewItem extends BaseActionViewItem {
|
|||
private _dropdown: DropdownMenuActionViewItem;
|
||||
private _container: HTMLElement | null = null;
|
||||
private _dropdownContainer: HTMLElement | null = null;
|
||||
private toDispose: IDisposable[];
|
||||
|
||||
constructor(
|
||||
primaryAction: MenuItemAction,
|
||||
|
@ -37,7 +35,6 @@ export class DropdownWithPrimaryActionViewItem extends BaseActionViewItem {
|
|||
this._dropdown = new DropdownMenuActionViewItem(dropdownAction, dropdownMenuActions, this._contextMenuProvider, {
|
||||
menuAsChild: true
|
||||
});
|
||||
this.toDispose = [];
|
||||
}
|
||||
|
||||
override render(container: HTMLElement): void {
|
||||
|
@ -48,7 +45,7 @@ export class DropdownWithPrimaryActionViewItem extends BaseActionViewItem {
|
|||
this._primaryAction.render(DOM.append(this._container, primaryContainer));
|
||||
this._dropdownContainer = DOM.$('.dropdown-action-container');
|
||||
this._dropdown.render(DOM.append(this._container, this._dropdownContainer));
|
||||
this.toDispose.push(DOM.addDisposableListener(primaryContainer, DOM.EventType.KEY_DOWN, (e: KeyboardEvent) => {
|
||||
this._register(DOM.addDisposableListener(primaryContainer, DOM.EventType.KEY_DOWN, (e: KeyboardEvent) => {
|
||||
const event = new StandardKeyboardEvent(e);
|
||||
if (event.equals(KeyCode.RightArrow)) {
|
||||
this._primaryAction.element!.tabIndex = -1;
|
||||
|
@ -56,7 +53,7 @@ export class DropdownWithPrimaryActionViewItem extends BaseActionViewItem {
|
|||
event.stopPropagation();
|
||||
}
|
||||
}));
|
||||
this.toDispose.push(DOM.addDisposableListener(this._dropdownContainer, DOM.EventType.KEY_DOWN, (e: KeyboardEvent) => {
|
||||
this._register(DOM.addDisposableListener(this._dropdownContainer, DOM.EventType.KEY_DOWN, (e: KeyboardEvent) => {
|
||||
const event = new StandardKeyboardEvent(e);
|
||||
if (event.equals(KeyCode.LeftArrow)) {
|
||||
this._primaryAction.element!.tabIndex = 0;
|
||||
|
@ -91,12 +88,8 @@ export class DropdownWithPrimaryActionViewItem extends BaseActionViewItem {
|
|||
}
|
||||
}
|
||||
|
||||
override dispose(): void {
|
||||
this.toDispose = dispose(this.toDispose);
|
||||
}
|
||||
|
||||
update(dropdownAction: IAction, dropdownMenuActions: IAction[], dropdownIcon?: string): void {
|
||||
this._dropdown?.dispose();
|
||||
this._dropdown.dispose();
|
||||
this._dropdown = new DropdownMenuActionViewItem(dropdownAction, dropdownMenuActions, this._contextMenuProvider, {
|
||||
menuAsChild: true,
|
||||
classNames: ['codicon', dropdownIcon || 'codicon-chevron-down']
|
||||
|
@ -105,4 +98,10 @@ export class DropdownWithPrimaryActionViewItem extends BaseActionViewItem {
|
|||
this._dropdown.render(this._dropdownContainer);
|
||||
}
|
||||
}
|
||||
|
||||
override dispose() {
|
||||
this._primaryAction.dispose();
|
||||
this._dropdown.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue