@@ -65,12 +65,12 @@ import { NotebookEventDispatcher } from 'vs/workbench/contrib/notebook/browser/v
6565import { MarkupCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/markupCellViewModel' ;
6666import { CellViewModel , NotebookViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/notebookViewModelImpl' ;
6767import { ViewContext } from 'vs/workbench/contrib/notebook/browser/viewModel/viewContext' ;
68- import { NotebookEditorToolbar } from 'vs/workbench/contrib/notebook/browser/viewParts/notebookEditorToolbar' ;
68+ import { NotebookEditorToolbar , NotebookEditorWorkbenchToolbar , RenderLabel , RenderLabelWithFallback , convertConfiguration } from 'vs/workbench/contrib/notebook/browser/viewParts/notebookEditorToolbar' ;
6969import { NotebookEditorContextKeys } from 'vs/workbench/contrib/notebook/browser/viewParts/notebookEditorWidgetContextKeys' ;
7070import { NotebookOverviewRuler } from 'vs/workbench/contrib/notebook/browser/viewParts/notebookOverviewRuler' ;
7171import { ListTopCellToolbar } from 'vs/workbench/contrib/notebook/browser/viewParts/notebookTopCellToolbar' ;
7272import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel' ;
73- import { CellEditType , CellKind , INotebookSearchOptions , RENDERER_NOT_AVAILABLE , SelectionStateType } from 'vs/workbench/contrib/notebook/common/notebookCommon' ;
73+ import { CellEditType , CellKind , INotebookSearchOptions , NotebookSetting , RENDERER_NOT_AVAILABLE , SelectionStateType } from 'vs/workbench/contrib/notebook/common/notebookCommon' ;
7474import { NOTEBOOK_CURSOR_NAVIGATION_MODE , NOTEBOOK_EDITOR_EDITABLE , NOTEBOOK_EDITOR_FOCUSED , NOTEBOOK_OUTPUT_FOCUSED , NOTEBOOK_OUPTUT_INPUT_FOCUSED } from 'vs/workbench/contrib/notebook/common/notebookContextKeys' ;
7575import { INotebookExecutionService } from 'vs/workbench/contrib/notebook/common/notebookExecutionService' ;
7676import { INotebookExecutionStateService } from 'vs/workbench/contrib/notebook/common/notebookExecutionStateService' ;
@@ -170,7 +170,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
170170 //#endregion
171171 private _overlayContainer ! : HTMLElement ;
172172 private _notebookTopToolbarContainer ! : HTMLElement ;
173- private _notebookTopToolbar ! : NotebookEditorToolbar ;
173+ private _notebookTopToolbar ! : NotebookEditorToolbar | NotebookEditorWorkbenchToolbar ;
174174 private _notebookOverviewRulerContainer ! : HTMLElement ;
175175 private _notebookOverviewRuler ! : NotebookOverviewRuler ;
176176 private _body ! : HTMLElement ;
@@ -1013,12 +1013,42 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
10131013 }
10141014
10151015 private _registerNotebookActionsToolbar ( ) {
1016- this . _notebookTopToolbar = this . _register ( this . instantiationService . createInstance ( NotebookEditorToolbar , this , this . scopedContextKeyService , this . _notebookOptions , this . _notebookTopToolbarContainer ) ) ;
1017- this . _register ( this . _notebookTopToolbar . onDidChangeVisibility ( ( ) => {
1018- if ( this . _dimension && this . _isVisible ) {
1019- this . layout ( this . _dimension ) ;
1016+ const store = new DisposableStore ( ) ;
1017+ let currentLabel = convertConfiguration ( this . configurationService . getValue < RenderLabelWithFallback > ( NotebookSetting . globalToolbarShowLabel ) ) ;
1018+
1019+ const render = ( ) => {
1020+ if ( currentLabel === RenderLabel . Dynamic ) {
1021+ this . _notebookTopToolbar = this . _register ( this . instantiationService . createInstance ( NotebookEditorToolbar , this , this . scopedContextKeyService , this . _notebookOptions , this . _notebookTopToolbarContainer ) ) ;
1022+ } else {
1023+ this . _notebookTopToolbar = this . _register ( this . instantiationService . createInstance ( NotebookEditorWorkbenchToolbar , this , this . scopedContextKeyService , this . _notebookOptions , this . _notebookTopToolbarContainer ) ) ;
1024+ }
1025+
1026+ store . add ( this . _notebookTopToolbar . onDidChangeVisibility ( ( ) => {
1027+ if ( this . _dimension && this . _isVisible ) {
1028+ this . layout ( this . _dimension ) ;
1029+ }
1030+ } ) ) ;
1031+ } ;
1032+
1033+ render ( ) ;
1034+
1035+ this . _register ( this . configurationService . onDidChangeConfiguration ( e => {
1036+ if ( ! e . affectsConfiguration ( NotebookSetting . globalToolbarShowLabel ) ) {
1037+ return ;
1038+ }
1039+ const newRenderLabel = convertConfiguration ( this . configurationService . getValue < RenderLabelWithFallback > ( NotebookSetting . globalToolbarShowLabel ) ) ;
1040+
1041+ if ( newRenderLabel !== currentLabel && ( newRenderLabel === RenderLabel . Dynamic || currentLabel === RenderLabel . Dynamic ) ) {
1042+ // switch to the other implementation
1043+ store . clear ( ) ;
1044+ this . _notebookTopToolbar . dispose ( ) ;
1045+ DOM . clearNode ( this . _notebookTopToolbarContainer ) ;
1046+ currentLabel = newRenderLabel ;
1047+ render ( ) ;
10201048 }
10211049 } ) ) ;
1050+
1051+ this . _register ( store ) ;
10221052 }
10231053
10241054 private _updateOutputRenderers ( ) {
0 commit comments