Skip to content

Commit

Permalink
updateOptions should only update overrideStyles when set (#171797)
Browse files Browse the repository at this point in the history
* updateOptions: only update overrideStyles when defined

* revert changes from 6d6d9bd
  • Loading branch information
aeschli committed Jan 20, 2023
1 parent 9b63d86 commit 124960d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
12 changes: 8 additions & 4 deletions src/vs/platform/list/browser/listService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,9 @@ export class WorkbenchList<T> extends List<T> {
override updateOptions(options: IWorkbenchListOptionsUpdate): void {
super.updateOptions(options);

this.updateStyles(options.overrideStyles);
if (options.overrideStyles !== undefined) {
this.updateStyles(options.overrideStyles);
}

if (options.multipleSelectionSupport !== undefined) {
this.listSupportsMultiSelect.set(!!options.multipleSelectionSupport);
Expand Down Expand Up @@ -441,7 +443,7 @@ export class WorkbenchPagedList<T> extends PagedList<T> {
override updateOptions(options: IWorkbenchListOptionsUpdate): void {
super.updateOptions(options);

if (options.overrideStyles) {
if (options.overrideStyles !== undefined) {
this.updateStyles(options.overrideStyles);
}

Expand Down Expand Up @@ -584,7 +586,9 @@ export class WorkbenchTable<TRow> extends Table<TRow> {
override updateOptions(options: IWorkbenchTableOptionsUpdate): void {
super.updateOptions(options);

this.updateStyles(options.overrideStyles);
if (options.overrideStyles !== undefined) {
this.updateStyles(options.overrideStyles);
}

if (options.multipleSelectionSupport !== undefined) {
this.listSupportsMultiSelect.set(!!options.multipleSelectionSupport);
Expand Down Expand Up @@ -935,7 +939,7 @@ export class WorkbenchDataTree<TInput, T, TFilterData = void> extends DataTree<T
override updateOptions(options: IWorkbenchDataTreeOptionsUpdate = {}): void {
super.updateOptions(options);

if (options.overrideStyles) {
if (options.overrideStyles !== undefined) {
this.internals.updateStyleOverrides(options.overrideStyles);
}

Expand Down
40 changes: 19 additions & 21 deletions src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,24 +185,6 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
private _shadowElement?: HTMLElement;
private _shadowElementViewInfo: { height: number; width: number; top: number; left: number } | null = null;

private _listStyleOverride = {
listBackground: notebookEditorBackground,
listActiveSelectionBackground: notebookEditorBackground,
listActiveSelectionForeground: foreground,
listFocusAndSelectionBackground: notebookEditorBackground,
listFocusAndSelectionForeground: foreground,
listFocusBackground: notebookEditorBackground,
listFocusForeground: foreground,
listHoverForeground: foreground,
listHoverBackground: notebookEditorBackground,
listHoverOutline: focusBorder,
listFocusOutline: focusBorder,
listInactiveSelectionBackground: notebookEditorBackground,
listInactiveSelectionForeground: foreground,
listInactiveFocusBackground: notebookEditorBackground,
listInactiveFocusOutline: notebookEditorBackground,
};

private readonly _editorFocus: IContextKey<boolean>;
private readonly _outputFocus: IContextKey<boolean>;
private readonly _editorEditable: IContextKey<boolean>;
Expand Down Expand Up @@ -865,7 +847,23 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
transformOptimization: false, //(isMacintosh && isNative) || getTitleBarStyle(this.configurationService, this.environmentService) === 'native',
initialSize: this._dimension,
styleController: (_suffix: string) => { return this._list; },
overrideStyles: this._listStyleOverride,
overrideStyles: {
listBackground: notebookEditorBackground,
listActiveSelectionBackground: notebookEditorBackground,
listActiveSelectionForeground: foreground,
listFocusAndSelectionBackground: notebookEditorBackground,
listFocusAndSelectionForeground: foreground,
listFocusBackground: notebookEditorBackground,
listFocusForeground: foreground,
listHoverForeground: foreground,
listHoverBackground: notebookEditorBackground,
listHoverOutline: focusBorder,
listFocusOutline: focusBorder,
listInactiveSelectionBackground: notebookEditorBackground,
listInactiveSelectionForeground: foreground,
listInactiveFocusBackground: notebookEditorBackground,
listInactiveFocusOutline: notebookEditorBackground,
},
accessibilityProvider: {
getAriaLabel: (element: CellViewModel) => {
if (!this.viewModel) {
Expand Down Expand Up @@ -1735,12 +1733,12 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
const newCellListHeight = Math.max(newBodyHeight - topInserToolbarHeight, 0);
if (this._list.getRenderHeight() < newCellListHeight) {
// the new dimension is larger than the list viewport, update its additional height first, otherwise the list view will move down a bit (as the `scrollBottom` will move down)
this._list.updateOptions({ additionalScrollHeight: this._allowScrollBeyondLastLine() ? Math.max(0, (newCellListHeight - 50)) : topInserToolbarHeight, overrideStyles: this._listStyleOverride });
this._list.updateOptions({ additionalScrollHeight: this._allowScrollBeyondLastLine() ? Math.max(0, (newCellListHeight - 50)) : topInserToolbarHeight });
this._list.layout(newCellListHeight, dimension.width);
} else {
// the new dimension is smaller than the list viewport, if we update the additional height, the `scrollBottom` will move up, which moves the whole list view upwards a bit. So we run a layout first.
this._list.layout(newCellListHeight, dimension.width);
this._list.updateOptions({ additionalScrollHeight: this._allowScrollBeyondLastLine() ? Math.max(0, (newCellListHeight - 50)) : topInserToolbarHeight, overrideStyles: this._listStyleOverride });
this._list.updateOptions({ additionalScrollHeight: this._allowScrollBeyondLastLine() ? Math.max(0, (newCellListHeight - 50)) : topInserToolbarHeight });
}

this._overlayContainer.style.visibility = 'visible';
Expand Down

0 comments on commit 124960d

Please sign in to comment.