Skip to content

Commit

Permalink
Fix focusIndicator cell part addition #131808
Browse files Browse the repository at this point in the history
  • Loading branch information
roblourens committed Mar 16, 2022
1 parent c79072c commit 6fa3243
Showing 1 changed file with 6 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 {
Expand All @@ -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) {
Expand All @@ -132,5 +119,4 @@ export class CellFocusIndicator extends CellPart {
this.right.domNode.style.transform = `translateY(${layoutInfo.cellTopMargin}px)`;
}
}

}

0 comments on commit 6fa3243

Please sign in to comment.