5
5
6
6
import * as DOM from 'vs/base/browser/dom' ;
7
7
import { FastDomNode } from 'vs/base/browser/fastDomNode' ;
8
- import { DisposableStore } from 'vs/base/common/lifecycle' ;
9
8
import { CodeCellLayoutInfo , ICellViewModel , INotebookEditorDelegate } from 'vs/workbench/contrib/notebook/browser/notebookBrowser' ;
10
9
import { CellViewModelStateChangeEvent } from 'vs/workbench/contrib/notebook/browser/notebookViewEvents' ;
11
10
import { CellPart } from 'vs/workbench/contrib/notebook/browser/view/cellParts/cellPart' ;
@@ -68,11 +67,14 @@ export class CellFocusIndicator extends CellPart {
68
67
this . currentElement . isOutputCollapsed = ! this . currentElement . isOutputCollapsed ;
69
68
}
70
69
} ) ) ;
70
+
71
+ this . _register ( this . titleToolbar . onDidUpdateActions ( ( ) => {
72
+ this . updateFocusIndicatorsForTitleMenu ( ) ;
73
+ } ) ) ;
71
74
}
72
75
73
76
renderCell ( element : ICellViewModel , templateData : BaseCellRenderTemplate ) : void {
74
77
this . currentElement = element ;
75
- this . updateFocusIndicatorsForTitleMenuAndSubscribe ( element , templateData . elementDisposables ) ;
76
78
}
77
79
78
80
prepareLayout ( ) : void {
@@ -99,29 +101,14 @@ export class CellFocusIndicator extends CellPart {
99
101
this . outputFocusIndicator . setHeight ( Math . max ( cell . layoutInfo . outputIndicatorHeight - cell . viewContext . notebookOptions . getLayoutConfiguration ( ) . focusIndicatorGap , 0 ) ) ;
100
102
this . bottom . domNode . style . transform = `translateY(${ cell . layoutInfo . totalHeight - bottomToolbarDimensions . bottomToolbarGap - layoutInfo . cellBottomMargin } px)` ;
101
103
}
104
+
105
+ this . updateFocusIndicatorsForTitleMenu ( ) ;
102
106
}
103
107
104
108
updateState ( element : ICellViewModel , e : CellViewModelStateChangeEvent ) : void {
105
109
// nothing to update
106
110
}
107
111
108
- private updateFocusIndicatorsForTitleMenuAndSubscribe ( element : ICellViewModel , disposables : DisposableStore ) {
109
- // todo@rebornix , consolidate duplicated requests in next frame
110
- disposables . add ( DOM . scheduleAtNextAnimationFrame ( ( ) => {
111
- this . updateFocusIndicatorsForTitleMenu ( ) ;
112
- } ) ) ;
113
-
114
- disposables . add ( element . onDidChangeLayout ( ( ) => {
115
- disposables . add ( DOM . scheduleAtNextAnimationFrame ( ( ) => {
116
- this . updateFocusIndicatorsForTitleMenu ( ) ;
117
- } ) ) ;
118
- } ) ) ;
119
-
120
- disposables . add ( this . titleToolbar . onDidUpdateActions ( ( ) => {
121
- this . updateFocusIndicatorsForTitleMenu ( ) ;
122
- } ) ) ;
123
- }
124
-
125
112
private updateFocusIndicatorsForTitleMenu ( ) : void {
126
113
const layoutInfo = this . notebookEditor . notebookOptions . getLayoutConfiguration ( ) ;
127
114
if ( this . titleToolbar . hasActions ) {
@@ -132,5 +119,4 @@ export class CellFocusIndicator extends CellPart {
132
119
this . right . domNode . style . transform = `translateY(${ layoutInfo . cellTopMargin } px)` ;
133
120
}
134
121
}
135
-
136
122
}
0 commit comments