Skip to content

Commit 3cdb21f

Browse files
committed
Interactive window- don't leave space for insert toolbar
1 parent a99c29b commit 3cdb21f

File tree

3 files changed

+33
-29
lines changed

3 files changed

+33
-29
lines changed

src/vs/workbench/contrib/interactive/browser/interactiveEditor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export class InteractiveEditor extends EditorPane {
148148
this.#notebookExecutionStateService = notebookExecutionStateService;
149149
this.#extensionService = extensionService;
150150

151-
this.#notebookOptions = new NotebookOptions(configurationService, notebookExecutionStateService, { cellToolbarInteraction: 'hover', globalToolbar: true, dragAndDropEnabled: false });
151+
this.#notebookOptions = new NotebookOptions(configurationService, notebookExecutionStateService, { cellToolbarInteraction: 'hover', globalToolbar: true, dragAndDropEnabled: false, insertToolbarBetweenCells: false });
152152
this.#editorMemento = this.getEditorMemento<InteractiveEditorViewState>(editorGroupService, textResourceConfigurationService, INTERACTIVE_EDITOR_VIEW_STATE_PREFERENCE_KEY);
153153

154154
codeEditorService.registerDecorationType('interactive-decoration', DECORATION_KEY, {});

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
598598
collapsedIndicatorHeight,
599599
compactView,
600600
focusIndicator,
601-
insertToolbarPosition,
601+
insertToolbarBetweenCells,
602602
insertToolbarAlignment,
603603
fontSize,
604604
outputFontSize,
@@ -716,7 +716,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
716716
}
717717

718718
// between cell insert toolbar
719-
if (insertToolbarPosition === 'betweenCells' || insertToolbarPosition === 'both') {
719+
if (insertToolbarBetweenCells) {
720720
styleSheets.push(`.monaco-workbench .notebookOverlay > .cell-list-container > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .monaco-list-row .cell-bottom-toolbar-container { display: flex; }`);
721721
styleSheets.push(`.monaco-workbench .notebookOverlay > .cell-list-container > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .cell-list-top-cell-toolbar-container { display: flex; }`);
722722
} else {

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

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export interface NotebookLayoutConfiguration {
5858
cellToolbarInteraction: string;
5959
compactView: boolean;
6060
focusIndicator: 'border' | 'gutter';
61-
insertToolbarPosition: 'betweenCells' | 'notebookToolbar' | 'both' | 'hidden';
61+
insertToolbarBetweenCells: boolean;
6262
insertToolbarAlignment: 'left' | 'center';
6363
globalToolbar: boolean;
6464
consolidatedOutputButton: boolean;
@@ -133,7 +133,7 @@ export class NotebookOptions extends Disposable {
133133
constructor(
134134
private readonly configurationService: IConfigurationService,
135135
private readonly notebookExecutionStateService: INotebookExecutionStateService,
136-
private readonly overrides?: { cellToolbarInteraction: string; globalToolbar: boolean; dragAndDropEnabled: boolean }
136+
private readonly overrides?: { cellToolbarInteraction: string; globalToolbar: boolean; dragAndDropEnabled: boolean; insertToolbarBetweenCells?: boolean }
137137
) {
138138
super();
139139
const showCellStatusBar = this.configurationService.getValue<ShowCellStatusBarType>(NotebookSetting.showCellStatusBar);
@@ -145,7 +145,7 @@ export class NotebookOptions extends Disposable {
145145
const cellToolbarInteraction = overrides?.cellToolbarInteraction ?? this.configurationService.getValue<string>(NotebookSetting.cellToolbarVisibility);
146146
const compactView = this.configurationService.getValue<boolean | undefined>(NotebookSetting.compactView) ?? true;
147147
const focusIndicator = this._computeFocusIndicatorOption();
148-
const insertToolbarPosition = this._computeInsertToolbarPositionOption();
148+
const insertToolbarBetweenCells = overrides?.insertToolbarBetweenCells ?? this._computeInsertToolbarBetweenCellsOption();
149149
const insertToolbarAlignment = this._computeInsertToolbarAlignmentOption();
150150
const showFoldingControls = this._computeShowFoldingControlsOption();
151151
// const { bottomToolbarGap, bottomToolbarHeight } = this._computeBottomToolbarDimensions(compactView, insertToolbarPosition, insertToolbarAlignment);
@@ -219,7 +219,7 @@ export class NotebookOptions extends Disposable {
219219
cellToolbarInteraction,
220220
compactView,
221221
focusIndicator,
222-
insertToolbarPosition,
222+
insertToolbarBetweenCells,
223223
insertToolbarAlignment,
224224
showFoldingControls,
225225
fontSize,
@@ -369,7 +369,7 @@ export class NotebookOptions extends Disposable {
369369
configuration.cellToolbarLocation = this.configurationService.getValue<string | { [key: string]: string }>(NotebookSetting.cellToolbarLocation) ?? { 'default': 'right' };
370370
}
371371

372-
if (cellToolbarInteraction && !this.overrides?.cellToolbarInteraction) {
372+
if (cellToolbarInteraction && this.overrides?.cellToolbarInteraction === undefined) {
373373
configuration.cellToolbarInteraction = this.configurationService.getValue<string>(NotebookSetting.cellToolbarVisibility);
374374
}
375375

@@ -389,8 +389,8 @@ export class NotebookOptions extends Disposable {
389389
configuration.insertToolbarAlignment = this._computeInsertToolbarAlignmentOption();
390390
}
391391

392-
if (insertToolbarPosition) {
393-
configuration.insertToolbarPosition = this._computeInsertToolbarPositionOption();
392+
if (insertToolbarPosition && this.overrides?.insertToolbarBetweenCells === undefined) {
393+
configuration.insertToolbarBetweenCells = this._computeInsertToolbarBetweenCellsOption();
394394
}
395395

396396
if (globalToolbar && this.overrides?.globalToolbar === undefined) {
@@ -479,8 +479,9 @@ export class NotebookOptions extends Disposable {
479479
});
480480
}
481481

482-
private _computeInsertToolbarPositionOption() {
483-
return this.configurationService.getValue<'betweenCells' | 'notebookToolbar' | 'both' | 'hidden'>(NotebookSetting.insertToolbarLocation) ?? 'both';
482+
private _computeInsertToolbarBetweenCellsOption() {
483+
const configValue = this.configurationService.getValue<'betweenCells' | 'notebookToolbar' | 'both' | 'hidden'>(NotebookSetting.insertToolbarLocation) ?? 'both';
484+
return configValue === 'betweenCells' || configValue === 'both';
484485
}
485486

486487
private _computeInsertToolbarAlignmentOption() {
@@ -547,34 +548,37 @@ export class NotebookOptions extends Disposable {
547548
return this._layoutConfiguration.cellStatusBarHeight;
548549
}
549550

550-
private _computeBottomToolbarDimensions(compactView: boolean, insertToolbarPosition: 'betweenCells' | 'notebookToolbar' | 'both' | 'hidden', insertToolbarAlignment: 'left' | 'center', cellToolbar: 'right' | 'left' | 'hidden'): { bottomToolbarGap: number; bottomToolbarHeight: number } {
551+
private _computeBottomToolbarDimensions(compactView: boolean, insertToolbarBetweenCells: boolean, insertToolbarAlignment: 'left' | 'center', cellToolbar: 'right' | 'left' | 'hidden'): { bottomToolbarGap: number; bottomToolbarHeight: number } {
552+
if (!insertToolbarBetweenCells) {
553+
return compactView ? {
554+
bottomToolbarGap: 0,
555+
bottomToolbarHeight: 0
556+
} : {
557+
bottomToolbarGap: 12,
558+
bottomToolbarHeight: 12
559+
};
560+
}
561+
551562
if (insertToolbarAlignment === 'left' || cellToolbar !== 'hidden') {
552563
return {
553564
bottomToolbarGap: 18,
554565
bottomToolbarHeight: 18
555566
};
556567
}
557568

558-
if (insertToolbarPosition === 'betweenCells' || insertToolbarPosition === 'both') {
559-
return compactView ? {
560-
bottomToolbarGap: 12,
561-
bottomToolbarHeight: 20
562-
} : {
563-
bottomToolbarGap: 20,
564-
bottomToolbarHeight: 20
565-
};
566-
} else {
567-
return {
568-
bottomToolbarGap: 0,
569-
bottomToolbarHeight: 0
570-
};
571-
}
569+
return compactView ? {
570+
bottomToolbarGap: 12,
571+
bottomToolbarHeight: 20
572+
} : {
573+
bottomToolbarGap: 20,
574+
bottomToolbarHeight: 20
575+
};
572576
}
573577

574578
computeBottomToolbarDimensions(viewType?: string): { bottomToolbarGap: number; bottomToolbarHeight: number } {
575579
const configuration = this._layoutConfiguration;
576580
const cellToolbarPosition = this.computeCellToolbarLocation(viewType);
577-
const { bottomToolbarGap, bottomToolbarHeight } = this._computeBottomToolbarDimensions(configuration.compactView, configuration.insertToolbarPosition, configuration.insertToolbarAlignment, cellToolbarPosition);
581+
const { bottomToolbarGap, bottomToolbarHeight } = this._computeBottomToolbarDimensions(configuration.compactView, configuration.insertToolbarBetweenCells, configuration.insertToolbarAlignment, cellToolbarPosition);
578582
return {
579583
bottomToolbarGap,
580584
bottomToolbarHeight
@@ -616,7 +620,7 @@ export class NotebookOptions extends Disposable {
616620
}
617621

618622
computeTopInsertToolbarHeight(viewType?: string): number {
619-
if (this._layoutConfiguration.insertToolbarPosition === 'betweenCells' || this._layoutConfiguration.insertToolbarPosition === 'both') {
623+
if (this._layoutConfiguration.insertToolbarBetweenCells) {
620624
return SCROLLABLE_ELEMENT_PADDING_TOP;
621625
}
622626

0 commit comments

Comments
 (0)