From 99665d0b4ac734861475eedeecb391bca4e4750d Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Wed, 2 Jun 2021 18:03:10 -0700 Subject: [PATCH] Merge cell statusbar settings Fix #125173 --- .../contrib/profile/notebookProfile.ts | 15 ++++++-------- .../notebook/browser/notebook.contribution.ts | 17 ++++++++-------- .../browser/viewModel/baseCellViewModel.ts | 4 ++-- .../contrib/notebook/common/notebookCommon.ts | 4 ++-- .../notebook/common/notebookOptions.ts | 20 +++++-------------- .../common/media/notebookProfile.ts | 6 +++--- 6 files changed, 26 insertions(+), 40 deletions(-) diff --git a/src/vs/workbench/contrib/notebook/browser/contrib/profile/notebookProfile.ts b/src/vs/workbench/contrib/notebook/browser/contrib/profile/notebookProfile.ts index c9258d39235..b30fe2a6a25 100644 --- a/src/vs/workbench/contrib/notebook/browser/contrib/profile/notebookProfile.ts +++ b/src/vs/workbench/contrib/notebook/browser/contrib/profile/notebookProfile.ts @@ -10,7 +10,7 @@ import { localize } from 'vs/nls'; import { Action2, registerAction2 } from 'vs/platform/actions/common/actions'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { optional } from 'vs/platform/instantiation/common/instantiation'; -import { CellToolbarLocation, CompactView, ConsolidatedRunButton, FocusIndicator, GlobalToolbar, InsertToolbarLocation, ShowCellStatusBarAfterExecuteKey, ShowCellStatusBarKey, UndoRedoPerCell } from 'vs/workbench/contrib/notebook/common/notebookCommon'; +import { CellToolbarLocation, CompactView, ConsolidatedRunButton, FocusIndicator, GlobalToolbar, InsertToolbarLocation, ShowCellStatusBar, UndoRedoPerCell } from 'vs/workbench/contrib/notebook/common/notebookCommon'; import { ITASExperimentService } from 'vs/workbench/services/experiment/common/experimentService'; import { Extensions as WorkbenchExtensions, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions'; import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle'; @@ -28,8 +28,7 @@ const profiles = { [GlobalToolbar]: false, [CellToolbarLocation]: { default: 'right' }, [CompactView]: true, - [ShowCellStatusBarKey]: true, - [ShowCellStatusBarAfterExecuteKey]: false, + [ShowCellStatusBar]: 'visible', [ConsolidatedRunButton]: true, [UndoRedoPerCell]: false }, @@ -39,7 +38,7 @@ const profiles = { [GlobalToolbar]: true, [CellToolbarLocation]: { default: 'left' }, [CompactView]: true, - [ShowCellStatusBarKey]: true, + [ShowCellStatusBar]: 'visible', [ConsolidatedRunButton]: false, [UndoRedoPerCell]: true }, @@ -49,7 +48,7 @@ const profiles = { [GlobalToolbar]: false, [CellToolbarLocation]: { default: 'right' }, [CompactView]: false, - [ShowCellStatusBarKey]: false, + [ShowCellStatusBar]: 'hidden', [ConsolidatedRunButton]: true, [UndoRedoPerCell]: false } @@ -108,16 +107,14 @@ export class NotebookProfileContribution extends Disposable { const globalToolbar = configService.getValue(GlobalToolbar); // const cellToolbarLocation = configService.getValue(CellToolbarLocation); const compactView = configService.getValue(CompactView); - const showCellStatusBarKey = configService.getValue(ShowCellStatusBarKey); - const showCellStatusBarAfterExecuteKey = configService.getValue(ShowCellStatusBarAfterExecuteKey); + const showCellStatusBar = configService.getValue(ShowCellStatusBar); const consolidatedRunButton = configService.getValue(ConsolidatedRunButton); if (focusIndicator === 'border' && insertToolbarPosition === 'both' && globalToolbar === false // && cellToolbarLocation === undefined && compactView === true - && showCellStatusBarKey === true - && showCellStatusBarAfterExecuteKey === false + && showCellStatusBar === 'visible' && consolidatedRunButton === true ) { applyProfile(configService, profiles[treatment] ?? profiles[NotebookProfileType.default]); diff --git a/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts b/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts index 8d748abc45e..5259562ea07 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts @@ -30,7 +30,7 @@ import { NotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookEd import { NotebookEditorInput } from 'vs/workbench/contrib/notebook/common/notebookEditorInput'; import { INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService'; import { NotebookService } from 'vs/workbench/contrib/notebook/browser/notebookServiceImpl'; -import { CellKind, CellToolbarLocation, CellToolbarVisibility, CellUri, DisplayOrderKey, UndoRedoPerCell, ExperimentalUseMarkdownRenderer, getCellUndoRedoComparisonKey, IResolvedNotebookEditorModel, NotebookDocumentBackupData, NotebookTextDiffEditorPreview, NotebookWorkingCopyTypeIdentifier, ShowCellStatusBarKey, CompactView, FocusIndicator, InsertToolbarLocation, GlobalToolbar, ConsolidatedOutputButton, ShowFoldingControls, DragAndDropEnabled, ShowCellStatusBarAfterExecuteKey, NotebookCellEditorOptionsCustomizations, ConsolidatedRunButton } from 'vs/workbench/contrib/notebook/common/notebookCommon'; +import { CellKind, CellToolbarLocation, CellToolbarVisibility, CellUri, DisplayOrderKey, UndoRedoPerCell, ExperimentalUseMarkdownRenderer, getCellUndoRedoComparisonKey, IResolvedNotebookEditorModel, NotebookDocumentBackupData, NotebookTextDiffEditorPreview, NotebookWorkingCopyTypeIdentifier, ShowCellStatusBar, CompactView, FocusIndicator, InsertToolbarLocation, GlobalToolbar, ConsolidatedOutputButton, ShowFoldingControls, DragAndDropEnabled, NotebookCellEditorOptionsCustomizations, ConsolidatedRunButton } from 'vs/workbench/contrib/notebook/common/notebookCommon'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo'; import { INotebookEditorModelResolverService } from 'vs/workbench/contrib/notebook/common/notebookEditorModelResolverService'; @@ -617,18 +617,17 @@ configurationRegistry.registerConfiguration({ }, tags: ['notebookLayout'] }, - [ShowCellStatusBarKey]: { + [ShowCellStatusBar]: { description: nls.localize('notebook.showCellStatusbar.description', "Whether the cell status bar should be shown."), - type: 'boolean', + type: 'string', + enum: ['hidden', 'visible', 'visibleAfterExecute'], + enumDescriptions: [ + nls.localize('notebook.showCellStatusbar.hidden.description', "The cell status bar is always hidden."), + nls.localize('notebook.showCellStatusbar.visible.description', "The cell status bar is always visible."), + nls.localize('notebook.showCellStatusbar.visibleAfterExecute.description', "The cell status bar is hidden until the cell has executed. Then it becomes visible to show the execution status.")], default: true, tags: ['notebookLayout'] }, - [ShowCellStatusBarAfterExecuteKey]: { - description: nls.localize('notebook.showCellStatusbarAfterExecute.description', "Whether the cell status bar should be shown after the cell has been executed. Only has an effect if notebook.showCellStatusBar is false."), - type: 'boolean', - default: false, - tags: ['notebookLayout'] - }, [NotebookTextDiffEditorPreview]: { description: nls.localize('notebook.diff.enablePreview.description', "Whether to use the enhanced text diff editor for notebook."), type: 'boolean', diff --git a/src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.ts b/src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.ts index a768023c05a..a3ad629f4bd 100644 --- a/src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.ts +++ b/src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.ts @@ -162,9 +162,9 @@ export abstract class BaseCellViewModel extends Disposable { } private statusBarIsVisible(): boolean { - if (this._viewContext.notebookOptions.getLayoutConfiguration().showCellStatusBar) { + if (this._viewContext.notebookOptions.getLayoutConfiguration().showCellStatusBar === 'visible') { return true; - } else if (this._viewContext.notebookOptions.getLayoutConfiguration().showCellStatusBarAfterExecute) { + } else if (this._viewContext.notebookOptions.getLayoutConfiguration().showCellStatusBar === 'visibleAfterExecute') { return typeof this.internalMetadata.lastRunSuccess === 'boolean' || this.internalMetadata.runState !== undefined; } else { return false; diff --git a/src/vs/workbench/contrib/notebook/common/notebookCommon.ts b/src/vs/workbench/contrib/notebook/common/notebookCommon.ts index 5abbe3e358f..53dc70fe35c 100644 --- a/src/vs/workbench/contrib/notebook/common/notebookCommon.ts +++ b/src/vs/workbench/contrib/notebook/common/notebookCommon.ts @@ -911,8 +911,8 @@ export interface INotebookCellStatusBarItemList { export const DisplayOrderKey = 'notebook.displayOrder'; export const CellToolbarLocation = 'notebook.cellToolbarLocation'; export const CellToolbarVisibility = 'notebook.cellToolbarVisibility'; -export const ShowCellStatusBarKey = 'notebook.showCellStatusBar'; -export const ShowCellStatusBarAfterExecuteKey = 'notebook.showCellStatusBarAfterExecute'; +export type ShowCellStatusBarType = 'hidden' | 'visible' | 'visibleAfterExecute'; +export const ShowCellStatusBar = 'notebook.showCellStatusBar'; export const NotebookTextDiffEditorPreview = 'notebook.diff.enablePreview'; export const ExperimentalUseMarkdownRenderer = 'notebook.experimental.useMarkdownRenderer'; export const ExperimentalInsertToolbarAlignment = 'notebook.experimental.insertToolbarAlignment'; diff --git a/src/vs/workbench/contrib/notebook/common/notebookOptions.ts b/src/vs/workbench/contrib/notebook/common/notebookOptions.ts index 031a976d119..6b4460a993a 100644 --- a/src/vs/workbench/contrib/notebook/common/notebookOptions.ts +++ b/src/vs/workbench/contrib/notebook/common/notebookOptions.ts @@ -6,7 +6,7 @@ import { Emitter } from 'vs/base/common/event'; import { IDisposable } from 'vs/base/common/lifecycle'; import { IConfigurationChangeEvent, IConfigurationService } from 'vs/platform/configuration/common/configuration'; -import { CellToolbarLocation, CellToolbarVisibility, CompactView, ConsolidatedOutputButton, ConsolidatedRunButton, DragAndDropEnabled, ExperimentalInsertToolbarAlignment, FocusIndicator, GlobalToolbar, InsertToolbarLocation, NotebookCellEditorOptionsCustomizations, ShowCellStatusBarAfterExecuteKey, ShowCellStatusBarKey, ShowFoldingControls } from 'vs/workbench/contrib/notebook/common/notebookCommon'; +import { CellToolbarLocation, CellToolbarVisibility, CompactView, ConsolidatedOutputButton, ConsolidatedRunButton, DragAndDropEnabled, ExperimentalInsertToolbarAlignment, FocusIndicator, GlobalToolbar, InsertToolbarLocation, NotebookCellEditorOptionsCustomizations, ShowCellStatusBar, ShowCellStatusBarType, ShowFoldingControls } from 'vs/workbench/contrib/notebook/common/notebookCommon'; const SCROLLABLE_ELEMENT_PADDING_TOP = 18; @@ -43,8 +43,7 @@ export interface NotebookLayoutConfiguration { editorBottomPadding: number; editorBottomPaddingWithoutStatusBar: number; collapsedIndicatorHeight: number; - showCellStatusBar: boolean; - showCellStatusBarAfterExecute: boolean; + showCellStatusBar: ShowCellStatusBarType; cellStatusBarHeight: number; cellToolbarLocation: string | { [key: string]: string }; cellToolbarInteraction: string; @@ -108,8 +107,7 @@ export class NotebookOptions { private _disposables: IDisposable[]; constructor(private readonly configurationService: IConfigurationService) { - const showCellStatusBar = this.configurationService.getValue(ShowCellStatusBarKey); - const showCellStatusBarAfterExecute = this.configurationService.getValue(ShowCellStatusBarAfterExecuteKey); + const showCellStatusBar = this.configurationService.getValue(ShowCellStatusBar); const globalToolbar = this.configurationService.getValue(GlobalToolbar) ?? false; const consolidatedOutputButton = this.configurationService.getValue(ConsolidatedOutputButton) ?? true; const consolidatedRunButton = this.configurationService.getValue(ConsolidatedRunButton) ?? false; @@ -142,7 +140,6 @@ export class NotebookOptions { editorBottomPaddingWithoutStatusBar: 12, collapsedIndicatorHeight: 24, showCellStatusBar, - showCellStatusBarAfterExecute, globalToolbar, consolidatedOutputButton, consolidatedRunButton, @@ -171,8 +168,7 @@ export class NotebookOptions { } private _updateConfiguration(e: IConfigurationChangeEvent) { - const cellStatusBarVisibility = e.affectsConfiguration(ShowCellStatusBarKey); - const cellStatusBarAfterExecuteVisibility = e.affectsConfiguration(ShowCellStatusBarAfterExecuteKey); + const cellStatusBarVisibility = e.affectsConfiguration(ShowCellStatusBar); const cellToolbarLocation = e.affectsConfiguration(CellToolbarLocation); const cellToolbarInteraction = e.affectsConfiguration(CellToolbarVisibility); const compactView = e.affectsConfiguration(CompactView); @@ -189,7 +185,6 @@ export class NotebookOptions { if ( !cellStatusBarVisibility - && !cellStatusBarAfterExecuteVisibility && !cellToolbarLocation && !cellToolbarInteraction && !compactView @@ -209,11 +204,7 @@ export class NotebookOptions { let configuration = Object.assign({}, this._layoutConfiguration); if (cellStatusBarVisibility) { - configuration.showCellStatusBar = this.configurationService.getValue(ShowCellStatusBarKey); - } - - if (cellStatusBarAfterExecuteVisibility) { - configuration.showCellStatusBarAfterExecute = this.configurationService.getValue(ShowCellStatusBarAfterExecuteKey); + configuration.showCellStatusBar = this.configurationService.getValue(ShowCellStatusBar); } if (cellToolbarLocation) { @@ -277,7 +268,6 @@ export class NotebookOptions { // trigger event this._onDidChangeOptions.fire({ cellStatusBarVisibility, - cellStatusBarAfterExecuteVisibility, cellToolbarLocation, cellToolbarInteraction, compactView, diff --git a/src/vs/workbench/contrib/welcome/gettingStarted/common/media/notebookProfile.ts b/src/vs/workbench/contrib/welcome/gettingStarted/common/media/notebookProfile.ts index 9c7f4d6e53c..00fe2b8367d 100644 --- a/src/vs/workbench/contrib/welcome/gettingStarted/common/media/notebookProfile.ts +++ b/src/vs/workbench/contrib/welcome/gettingStarted/common/media/notebookProfile.ts @@ -12,15 +12,15 @@ const imageSize = 400; export default () => ` - + ${escape(localize('default', "Default"))} - + ${escape(localize('jupyter', "Jupyter"))} - + ${escape(localize('colab', "Colab"))}