@@ -65,12 +65,12 @@ import { NotebookEventDispatcher } from 'vs/workbench/contrib/notebook/browser/v
65
65
import { MarkupCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/markupCellViewModel' ;
66
66
import { CellViewModel , NotebookViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/notebookViewModelImpl' ;
67
67
import { 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' ;
69
69
import { NotebookEditorContextKeys } from 'vs/workbench/contrib/notebook/browser/viewParts/notebookEditorWidgetContextKeys' ;
70
70
import { NotebookOverviewRuler } from 'vs/workbench/contrib/notebook/browser/viewParts/notebookOverviewRuler' ;
71
71
import { ListTopCellToolbar } from 'vs/workbench/contrib/notebook/browser/viewParts/notebookTopCellToolbar' ;
72
72
import { 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' ;
74
74
import { NOTEBOOK_CURSOR_NAVIGATION_MODE , NOTEBOOK_EDITOR_EDITABLE , NOTEBOOK_EDITOR_FOCUSED , NOTEBOOK_OUTPUT_FOCUSED , NOTEBOOK_OUPTUT_INPUT_FOCUSED } from 'vs/workbench/contrib/notebook/common/notebookContextKeys' ;
75
75
import { INotebookExecutionService } from 'vs/workbench/contrib/notebook/common/notebookExecutionService' ;
76
76
import { INotebookExecutionStateService } from 'vs/workbench/contrib/notebook/common/notebookExecutionStateService' ;
@@ -170,7 +170,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
170
170
//#endregion
171
171
private _overlayContainer ! : HTMLElement ;
172
172
private _notebookTopToolbarContainer ! : HTMLElement ;
173
- private _notebookTopToolbar ! : NotebookEditorToolbar ;
173
+ private _notebookTopToolbar ! : NotebookEditorToolbar | NotebookEditorWorkbenchToolbar ;
174
174
private _notebookOverviewRulerContainer ! : HTMLElement ;
175
175
private _notebookOverviewRuler ! : NotebookOverviewRuler ;
176
176
private _body ! : HTMLElement ;
@@ -1013,12 +1013,42 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
1013
1013
}
1014
1014
1015
1015
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 ( ) ;
1020
1048
}
1021
1049
} ) ) ;
1050
+
1051
+ this . _register ( store ) ;
1022
1052
}
1023
1053
1024
1054
private _updateOutputRenderers ( ) {
0 commit comments