From 32a0c9ede4809dc5bb76da1449a3d72602ec279c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Moreno?= Date: Thu, 11 Jun 2020 20:12:11 +0200 Subject: [PATCH] propagate horizontal scrolling setting update through workbench widgets --- src/vs/base/browser/ui/list/listPaging.ts | 6 ++- src/vs/base/browser/ui/tree/abstractTree.ts | 3 +- src/vs/platform/list/browser/listService.ts | 44 ++++++++++++++------- 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/src/vs/base/browser/ui/list/listPaging.ts b/src/vs/base/browser/ui/list/listPaging.ts index 508fb3dcabd..41bfa24ee60 100644 --- a/src/vs/base/browser/ui/list/listPaging.ts +++ b/src/vs/base/browser/ui/list/listPaging.ts @@ -7,7 +7,7 @@ import 'vs/css!./list'; import { IDisposable, Disposable } from 'vs/base/common/lifecycle'; import { range } from 'vs/base/common/arrays'; import { IListVirtualDelegate, IListRenderer, IListEvent, IListContextMenuEvent } from './list'; -import { List, IListStyles, IListOptions, IListAccessibilityProvider } from './listWidget'; +import { List, IListStyles, IListOptions, IListAccessibilityProvider, IListOptionsUpdate } from './listWidget'; import { IPagedModel } from 'vs/base/common/paging'; import { Event } from 'vs/base/common/event'; import { CancellationTokenSource } from 'vs/base/common/cancellation'; @@ -136,6 +136,10 @@ export class PagedList implements IDisposable { this.list = new List(user, container, virtualDelegate, pagedRenderers, fromPagedListOptions(modelProvider, options)); } + updateOptions(options: IListOptionsUpdate) { + this.list.updateOptions(options); + } + getHTMLElement(): HTMLElement { return this.list.getHTMLElement(); } diff --git a/src/vs/base/browser/ui/tree/abstractTree.ts b/src/vs/base/browser/ui/tree/abstractTree.ts index 1a14e74e656..ce980749702 100644 --- a/src/vs/base/browser/ui/tree/abstractTree.ts +++ b/src/vs/base/browser/ui/tree/abstractTree.ts @@ -1361,7 +1361,8 @@ export abstract class AbstractTree implements IDisposable this.view.updateOptions({ enableKeyboardNavigation: this._options.simpleKeyboardNavigation, automaticKeyboardNavigation: this._options.automaticKeyboardNavigation, - smoothScrolling: this._options.smoothScrolling + smoothScrolling: this._options.smoothScrolling, + horizontalScrolling: this._options.horizontalScrolling }); if (this.typeFilterController) { diff --git a/src/vs/platform/list/browser/listService.ts b/src/vs/platform/list/browser/listService.ts index 8fb851a482a..3c9f08288cf 100644 --- a/src/vs/platform/list/browser/listService.ts +++ b/src/vs/platform/list/browser/listService.ts @@ -244,6 +244,7 @@ export class WorkbenchList extends List { private listHasSelectionOrFocus: IContextKey; private listDoubleSelection: IContextKey; private listMultiSelection: IContextKey; + private horizontalScrolling: boolean | undefined; private _styler: IDisposable | undefined; private _useAltAsMultipleSelectionModifier: boolean; @@ -284,6 +285,7 @@ export class WorkbenchList extends List { this.listHasSelectionOrFocus = WorkbenchListHasSelectionOrFocus.bindTo(this.contextKeyService); this.listDoubleSelection = WorkbenchListDoubleSelection.bindTo(this.contextKeyService); this.listMultiSelection = WorkbenchListMultiSelection.bindTo(this.contextKeyService); + this.horizontalScrolling = options.horizontalScrolling; this._useAltAsMultipleSelectionModifier = useAltAsMultipleSelectionModifier(configurationService); @@ -340,6 +342,10 @@ export class WorkbenchList extends List { if (e.affectsConfiguration(multiSelectModifierSettingKey)) { this._useAltAsMultipleSelectionModifier = useAltAsMultipleSelectionModifier(this.configurationService); } + if (e.affectsConfiguration(horizontalScrollingKey) && this.horizontalScrolling === undefined) { + const horizontalScrolling = this.configurationService.getValue(horizontalScrollingKey); + this.updateOptions({ horizontalScrolling }); + } })); } @@ -360,6 +366,7 @@ export class WorkbenchPagedList extends PagedList { private readonly disposables: DisposableStore; private _useAltAsMultipleSelectionModifier: boolean; + private horizontalScrolling: boolean | undefined; constructor( user: string, @@ -389,6 +396,7 @@ export class WorkbenchPagedList extends PagedList { this.contextKeyService = createScopedContextKeyService(contextKeyService, this); this.configurationService = configurationService; + this.horizontalScrolling = options.horizontalScrolling; const listSupportsMultiSelect = WorkbenchListSupportsMultiSelectContextKey.bindTo(this.contextKeyService); listSupportsMultiSelect.set(!(options.multipleSelectionSupport === false)); @@ -410,6 +418,10 @@ export class WorkbenchPagedList extends PagedList { if (e.affectsConfiguration(multiSelectModifierSettingKey)) { this._useAltAsMultipleSelectionModifier = useAltAsMultipleSelectionModifier(this.configurationService); } + if (e.affectsConfiguration(horizontalScrollingKey) && this.horizontalScrolling === undefined) { + const horizontalScrolling = this.configurationService.getValue(horizontalScrollingKey); + this.updateOptions({ horizontalScrolling }); + } })); } @@ -608,7 +620,7 @@ export class WorkbenchObjectTree, TFilterData = void> const { options: treeOptions, getAutomaticKeyboardNavigation, disposable } = workbenchTreeDataPreamble>(container, options, contextKeyService, configurationService, keybindingService, accessibilityService); super(user, container, delegate, renderers, treeOptions); this.disposables.add(disposable); - this.internals = new WorkbenchTreeInternals(this, treeOptions, getAutomaticKeyboardNavigation, options.overrideStyles, contextKeyService, listService, themeService, configurationService, accessibilityService); + this.internals = new WorkbenchTreeInternals(this, options, getAutomaticKeyboardNavigation, options.overrideStyles, contextKeyService, listService, themeService, configurationService, accessibilityService); this.disposables.add(this.internals); } } @@ -643,7 +655,7 @@ export class WorkbenchCompressibleObjectTree, TFilter const { options: treeOptions, getAutomaticKeyboardNavigation, disposable } = workbenchTreeDataPreamble>(container, options, contextKeyService, configurationService, keybindingService, accessibilityService); super(user, container, delegate, renderers, treeOptions); this.disposables.add(disposable); - this.internals = new WorkbenchTreeInternals(this, treeOptions, getAutomaticKeyboardNavigation, options.overrideStyles, contextKeyService, listService, themeService, configurationService, accessibilityService); + this.internals = new WorkbenchTreeInternals(this, options, getAutomaticKeyboardNavigation, options.overrideStyles, contextKeyService, listService, themeService, configurationService, accessibilityService); this.disposables.add(this.internals); } @@ -687,7 +699,7 @@ export class WorkbenchDataTree extends DataTree>(container, options, contextKeyService, configurationService, keybindingService, accessibilityService); super(user, container, delegate, renderers, dataSource, treeOptions); this.disposables.add(disposable); - this.internals = new WorkbenchTreeInternals(this, treeOptions, getAutomaticKeyboardNavigation, options.overrideStyles, contextKeyService, listService, themeService, configurationService, accessibilityService); + this.internals = new WorkbenchTreeInternals(this, options, getAutomaticKeyboardNavigation, options.overrideStyles, contextKeyService, listService, themeService, configurationService, accessibilityService); this.disposables.add(this.internals); } @@ -731,7 +743,7 @@ export class WorkbenchAsyncDataTree extends Async const { options: treeOptions, getAutomaticKeyboardNavigation, disposable } = workbenchTreeDataPreamble>(container, options, contextKeyService, configurationService, keybindingService, accessibilityService); super(user, container, delegate, renderers, dataSource, treeOptions); this.disposables.add(disposable); - this.internals = new WorkbenchTreeInternals(this, treeOptions, getAutomaticKeyboardNavigation, options.overrideStyles, contextKeyService, listService, themeService, configurationService, accessibilityService); + this.internals = new WorkbenchTreeInternals(this, options, getAutomaticKeyboardNavigation, options.overrideStyles, contextKeyService, listService, themeService, configurationService, accessibilityService); this.disposables.add(this.internals); } @@ -773,7 +785,7 @@ export class WorkbenchCompressibleAsyncDataTree e const { options: treeOptions, getAutomaticKeyboardNavigation, disposable } = workbenchTreeDataPreamble>(container, options, contextKeyService, configurationService, keybindingService, accessibilityService); super(user, container, virtualDelegate, compressionDelegate, renderers, dataSource, treeOptions); this.disposables.add(disposable); - this.internals = new WorkbenchTreeInternals(this, treeOptions, getAutomaticKeyboardNavigation, options.overrideStyles, contextKeyService, listService, themeService, configurationService, accessibilityService); + this.internals = new WorkbenchTreeInternals(this, options, getAutomaticKeyboardNavigation, options.overrideStyles, contextKeyService, listService, themeService, configurationService, accessibilityService); this.disposables.add(this.internals); } } @@ -806,7 +818,7 @@ function workbenchTreeDataPreamble(keyboardNavigationSettingKey); - const horizontalScrolling = typeof options.horizontalScrolling !== 'undefined' ? options.horizontalScrolling : configurationService.getValue(horizontalScrollingKey); + const horizontalScrolling = options.horizontalScrolling !== undefined ? options.horizontalScrolling : configurationService.getValue(horizontalScrollingKey); const openOnSingleClick = useSingleClickToOpen(configurationService); const [workbenchListOptions, disposable] = toWorkbenchListOptions(options, configurationService, keybindingService); const additionalScrollHeight = options.additionalScrollHeight; @@ -896,33 +908,37 @@ class WorkbenchTreeInternals { this.hasSelectionOrFocus.set(selection.length > 0 || focus.length > 0); }), configurationService.onDidChangeConfiguration(e => { - let options: any = {}; + let newOptions: any = {}; if (e.affectsConfiguration(openModeSettingKey)) { - options = { ...options, openOnSingleClick: useSingleClickToOpen(configurationService) }; + newOptions = { ...newOptions, openOnSingleClick: useSingleClickToOpen(configurationService) }; } if (e.affectsConfiguration(multiSelectModifierSettingKey)) { this._useAltAsMultipleSelectionModifier = useAltAsMultipleSelectionModifier(configurationService); } if (e.affectsConfiguration(treeIndentKey)) { const indent = configurationService.getValue(treeIndentKey); - options = { ...options, indent }; + newOptions = { ...newOptions, indent }; } if (e.affectsConfiguration(treeRenderIndentGuidesKey)) { const renderIndentGuides = configurationService.getValue(treeRenderIndentGuidesKey); - options = { ...options, renderIndentGuides }; + newOptions = { ...newOptions, renderIndentGuides }; } if (e.affectsConfiguration(listSmoothScrolling)) { const smoothScrolling = configurationService.getValue(listSmoothScrolling); - options = { ...options, smoothScrolling }; + newOptions = { ...newOptions, smoothScrolling }; } if (e.affectsConfiguration(keyboardNavigationSettingKey)) { updateKeyboardNavigation(); } if (e.affectsConfiguration(automaticKeyboardNavigationSettingKey)) { - options = { ...options, automaticKeyboardNavigation: getAutomaticKeyboardNavigation() }; + newOptions = { ...newOptions, automaticKeyboardNavigation: getAutomaticKeyboardNavigation() }; + } + if (e.affectsConfiguration(horizontalScrollingKey) && options.horizontalScrolling === undefined) { + const horizontalScrolling = configurationService.getValue(horizontalScrollingKey); + newOptions = { ...newOptions, horizontalScrolling }; } - if (Object.keys(options).length > 0) { - tree.updateOptions(options); + if (Object.keys(newOptions).length > 0) { + tree.updateOptions(newOptions); } }), this.contextKeyService.onDidChangeContext(e => { -- GitLab