提交 bc3a770b 编写于 作者: J Johannes Rieken

perf - suggest status shouldn't listen when hidden

上级 dcda88e5
...@@ -435,6 +435,7 @@ export class SuggestWidget implements IDisposable { ...@@ -435,6 +435,7 @@ export class SuggestWidget implements IDisposable {
case State.Hidden: case State.Hidden:
dom.hide(this._messageElement, this._listElement, this._status.element); dom.hide(this._messageElement, this._listElement, this._status.element);
this._details.hide(true); this._details.hide(true);
this._status.hide();
this._contentWidget.hide(); this._contentWidget.hide();
this._ctxSuggestWidgetVisible.reset(); this._ctxSuggestWidgetVisible.reset();
this._ctxSuggestWidgetMultipleSuggestions.reset(); this._ctxSuggestWidgetMultipleSuggestions.reset();
...@@ -482,6 +483,7 @@ export class SuggestWidget implements IDisposable { ...@@ -482,6 +483,7 @@ export class SuggestWidget implements IDisposable {
} }
private _show(): void { private _show(): void {
this._status.show();
this._contentWidget.show(); this._contentWidget.show();
this._layout(this._persistedSize.restore()); this._layout(this._persistedSize.restore());
this._ctxSuggestWidgetVisible.set(true); this._ctxSuggestWidgetVisible.set(true);
......
...@@ -36,28 +36,35 @@ export class SuggestWidgetStatus { ...@@ -36,28 +36,35 @@ export class SuggestWidgetStatus {
readonly element: HTMLElement; readonly element: HTMLElement;
private readonly _disposables = new DisposableStore(); private readonly _leftActions: ActionBar;
private readonly _rightActions: ActionBar;
private readonly _menuDisposables = new DisposableStore();
constructor( constructor(
container: HTMLElement, container: HTMLElement,
@IInstantiationService instantiationService: IInstantiationService, @IInstantiationService instantiationService: IInstantiationService,
@IMenuService menuService: IMenuService, @IMenuService private _menuService: IMenuService,
@IContextKeyService contextKeyService: IContextKeyService, @IContextKeyService private _contextKeyService: IContextKeyService,
) { ) {
this.element = dom.append(container, dom.$('.suggest-status-bar')); this.element = dom.append(container, dom.$('.suggest-status-bar'));
const actionViewItemProvider = <IActionViewItemProvider>(action => { const actionViewItemProvider = <IActionViewItemProvider>(action => {
return action instanceof MenuItemAction return action instanceof MenuItemAction ? instantiationService.createInstance(StatusBarViewItem, action) : undefined;
? instantiationService.createInstance(StatusBarViewItem, action)
: undefined;
}); });
const leftActions = new ActionBar(this.element, { actionViewItemProvider }); this._leftActions = new ActionBar(this.element, { actionViewItemProvider });
const rightActions = new ActionBar(this.element, { actionViewItemProvider }); this._rightActions = new ActionBar(this.element, { actionViewItemProvider });
const menu = menuService.createMenu(suggestWidgetStatusbarMenu, contextKeyService);
leftActions.domNode.classList.add('left'); this._leftActions.domNode.classList.add('left');
rightActions.domNode.classList.add('right'); this._rightActions.domNode.classList.add('right');
}
dispose(): void {
this._menuDisposables.dispose();
this.element.remove();
}
show(): void {
const menu = this._menuService.createMenu(suggestWidgetStatusbarMenu, this._contextKeyService);
const renderMenu = () => { const renderMenu = () => {
const left: IAction[] = []; const left: IAction[] = [];
const right: IAction[] = []; const right: IAction[] = [];
...@@ -68,17 +75,16 @@ export class SuggestWidgetStatus { ...@@ -68,17 +75,16 @@ export class SuggestWidgetStatus {
right.push(...actions); right.push(...actions);
} }
} }
leftActions.clear(); this._leftActions.clear();
leftActions.push(left); this._leftActions.push(left);
rightActions.clear(); this._rightActions.clear();
rightActions.push(right); this._rightActions.push(right);
}; };
this._disposables.add(menu.onDidChange(() => renderMenu())); this._menuDisposables.add(menu.onDidChange(() => renderMenu()));
this._disposables.add(menu); this._menuDisposables.add(menu);
} }
dispose(): void { hide(): void {
this._disposables.dispose(); this._menuDisposables.clear();
this.element.remove();
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册