Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updateOptions should only update overrideStyles when set #171797

Merged
merged 3 commits into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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