Skip to content

Commit a0b88b5

Browse files
authored
NB toolbar -- dynamic resizing w/ workbench (microsoft#185404)
* dynamic sizing support * separator fix, double (+) fix, generic overflow fxn * comment cleaning...
1 parent 97f3d5b commit a0b88b5

File tree

2 files changed

+109
-644
lines changed

2 files changed

+109
-644
lines changed

src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ import { NotebookEventDispatcher } from 'vs/workbench/contrib/notebook/browser/v
6565
import { MarkupCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/markupCellViewModel';
6666
import { CellViewModel, NotebookViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/notebookViewModelImpl';
6767
import { ViewContext } from 'vs/workbench/contrib/notebook/browser/viewModel/viewContext';
68-
import { NotebookEditorToolbar, NotebookEditorWorkbenchToolbar, RenderLabel, RenderLabelWithFallback, convertConfiguration } from 'vs/workbench/contrib/notebook/browser/viewParts/notebookEditorToolbar';
68+
import { NotebookEditorWorkbenchToolbar } from 'vs/workbench/contrib/notebook/browser/viewParts/notebookEditorToolbar';
6969
import { NotebookEditorContextKeys } from 'vs/workbench/contrib/notebook/browser/viewParts/notebookEditorWidgetContextKeys';
7070
import { NotebookOverviewRuler } from 'vs/workbench/contrib/notebook/browser/viewParts/notebookOverviewRuler';
7171
import { ListTopCellToolbar } from 'vs/workbench/contrib/notebook/browser/viewParts/notebookTopCellToolbar';
7272
import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel';
73-
import { CellEditType, CellKind, INotebookSearchOptions, NotebookSetting, RENDERER_NOT_AVAILABLE, SelectionStateType } from 'vs/workbench/contrib/notebook/common/notebookCommon';
73+
import { CellEditType, CellKind, INotebookSearchOptions, RENDERER_NOT_AVAILABLE, SelectionStateType } from 'vs/workbench/contrib/notebook/common/notebookCommon';
7474
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';
7575
import { INotebookExecutionService } from 'vs/workbench/contrib/notebook/common/notebookExecutionService';
7676
import { 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 | NotebookEditorWorkbenchToolbar;
173+
private _notebookTopToolbar!: NotebookEditorWorkbenchToolbar;
174174
private _notebookOverviewRulerContainer!: HTMLElement;
175175
private _notebookOverviewRuler!: NotebookOverviewRuler;
176176
private _body!: HTMLElement;
@@ -1013,42 +1013,12 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
10131013
}
10141014

10151015
private _registerNotebookActionsToolbar() {
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();
1016+
this._notebookTopToolbar = this._register(this.instantiationService.createInstance(NotebookEditorWorkbenchToolbar, this, this.scopedContextKeyService, this._notebookOptions, this._notebookTopToolbarContainer));
1017+
this._register(this._notebookTopToolbar.onDidChangeVisibility(() => {
1018+
if (this._dimension && this._isVisible) {
1019+
this.layout(this._dimension);
10481020
}
10491021
}));
1050-
1051-
this._register(store);
10521022
}
10531023

10541024
private _updateOutputRenderers() {

0 commit comments

Comments
 (0)