From 6fa3243d3facbbf8b87222bcf4e81c5eddf5d47f Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Tue, 15 Mar 2022 19:30:08 -0700 Subject: [PATCH] Fix focusIndicator cell part addition #131808 --- .../view/cellParts/cellFocusIndicator.ts | 26 +++++-------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellFocusIndicator.ts b/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellFocusIndicator.ts index 7e85e76592b09..d3f1975b57d94 100644 --- a/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellFocusIndicator.ts +++ b/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellFocusIndicator.ts @@ -5,7 +5,6 @@ import * as DOM from 'vs/base/browser/dom'; import { FastDomNode } from 'vs/base/browser/fastDomNode'; -import { DisposableStore } from 'vs/base/common/lifecycle'; import { CodeCellLayoutInfo, ICellViewModel, INotebookEditorDelegate } from 'vs/workbench/contrib/notebook/browser/notebookBrowser'; import { CellViewModelStateChangeEvent } from 'vs/workbench/contrib/notebook/browser/notebookViewEvents'; import { CellPart } from 'vs/workbench/contrib/notebook/browser/view/cellParts/cellPart'; @@ -68,11 +67,14 @@ export class CellFocusIndicator extends CellPart { this.currentElement.isOutputCollapsed = !this.currentElement.isOutputCollapsed; } })); + + this._register(this.titleToolbar.onDidUpdateActions(() => { + this.updateFocusIndicatorsForTitleMenu(); + })); } renderCell(element: ICellViewModel, templateData: BaseCellRenderTemplate): void { this.currentElement = element; - this.updateFocusIndicatorsForTitleMenuAndSubscribe(element, templateData.elementDisposables); } prepareLayout(): void { @@ -99,29 +101,14 @@ export class CellFocusIndicator extends CellPart { this.outputFocusIndicator.setHeight(Math.max(cell.layoutInfo.outputIndicatorHeight - cell.viewContext.notebookOptions.getLayoutConfiguration().focusIndicatorGap, 0)); this.bottom.domNode.style.transform = `translateY(${cell.layoutInfo.totalHeight - bottomToolbarDimensions.bottomToolbarGap - layoutInfo.cellBottomMargin}px)`; } + + this.updateFocusIndicatorsForTitleMenu(); } updateState(element: ICellViewModel, e: CellViewModelStateChangeEvent): void { // nothing to update } - private updateFocusIndicatorsForTitleMenuAndSubscribe(element: ICellViewModel, disposables: DisposableStore) { - // todo@rebornix, consolidate duplicated requests in next frame - disposables.add(DOM.scheduleAtNextAnimationFrame(() => { - this.updateFocusIndicatorsForTitleMenu(); - })); - - disposables.add(element.onDidChangeLayout(() => { - disposables.add(DOM.scheduleAtNextAnimationFrame(() => { - this.updateFocusIndicatorsForTitleMenu(); - })); - })); - - disposables.add(this.titleToolbar.onDidUpdateActions(() => { - this.updateFocusIndicatorsForTitleMenu(); - })); - } - private updateFocusIndicatorsForTitleMenu(): void { const layoutInfo = this.notebookEditor.notebookOptions.getLayoutConfiguration(); if (this.titleToolbar.hasActions) { @@ -132,5 +119,4 @@ export class CellFocusIndicator extends CellPart { this.right.domNode.style.transform = `translateY(${layoutInfo.cellTopMargin}px)`; } } - }