Skip to content

Commit 32a0c9e

Browse files
committed
propagate horizontal scrolling setting update through workbench widgets
1 parent 5dd0eb4 commit 32a0c9e

3 files changed

Lines changed: 37 additions & 16 deletions

File tree

src/vs/base/browser/ui/list/listPaging.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'vs/css!./list';
77
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
88
import { range } from 'vs/base/common/arrays';
99
import { IListVirtualDelegate, IListRenderer, IListEvent, IListContextMenuEvent } from './list';
10-
import { List, IListStyles, IListOptions, IListAccessibilityProvider } from './listWidget';
10+
import { List, IListStyles, IListOptions, IListAccessibilityProvider, IListOptionsUpdate } from './listWidget';
1111
import { IPagedModel } from 'vs/base/common/paging';
1212
import { Event } from 'vs/base/common/event';
1313
import { CancellationTokenSource } from 'vs/base/common/cancellation';
@@ -136,6 +136,10 @@ export class PagedList<T> implements IDisposable {
136136
this.list = new List(user, container, virtualDelegate, pagedRenderers, fromPagedListOptions(modelProvider, options));
137137
}
138138

139+
updateOptions(options: IListOptionsUpdate) {
140+
this.list.updateOptions(options);
141+
}
142+
139143
getHTMLElement(): HTMLElement {
140144
return this.list.getHTMLElement();
141145
}

src/vs/base/browser/ui/tree/abstractTree.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,8 @@ export abstract class AbstractTree<T, TFilterData, TRef> implements IDisposable
13611361
this.view.updateOptions({
13621362
enableKeyboardNavigation: this._options.simpleKeyboardNavigation,
13631363
automaticKeyboardNavigation: this._options.automaticKeyboardNavigation,
1364-
smoothScrolling: this._options.smoothScrolling
1364+
smoothScrolling: this._options.smoothScrolling,
1365+
horizontalScrolling: this._options.horizontalScrolling
13651366
});
13661367

13671368
if (this.typeFilterController) {

src/vs/platform/list/browser/listService.ts

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ export class WorkbenchList<T> extends List<T> {
244244
private listHasSelectionOrFocus: IContextKey<boolean>;
245245
private listDoubleSelection: IContextKey<boolean>;
246246
private listMultiSelection: IContextKey<boolean>;
247+
private horizontalScrolling: boolean | undefined;
247248

248249
private _styler: IDisposable | undefined;
249250
private _useAltAsMultipleSelectionModifier: boolean;
@@ -284,6 +285,7 @@ export class WorkbenchList<T> extends List<T> {
284285
this.listHasSelectionOrFocus = WorkbenchListHasSelectionOrFocus.bindTo(this.contextKeyService);
285286
this.listDoubleSelection = WorkbenchListDoubleSelection.bindTo(this.contextKeyService);
286287
this.listMultiSelection = WorkbenchListMultiSelection.bindTo(this.contextKeyService);
288+
this.horizontalScrolling = options.horizontalScrolling;
287289

288290
this._useAltAsMultipleSelectionModifier = useAltAsMultipleSelectionModifier(configurationService);
289291

@@ -340,6 +342,10 @@ export class WorkbenchList<T> extends List<T> {
340342
if (e.affectsConfiguration(multiSelectModifierSettingKey)) {
341343
this._useAltAsMultipleSelectionModifier = useAltAsMultipleSelectionModifier(this.configurationService);
342344
}
345+
if (e.affectsConfiguration(horizontalScrollingKey) && this.horizontalScrolling === undefined) {
346+
const horizontalScrolling = this.configurationService.getValue<boolean>(horizontalScrollingKey);
347+
this.updateOptions({ horizontalScrolling });
348+
}
343349
}));
344350
}
345351

@@ -360,6 +366,7 @@ export class WorkbenchPagedList<T> extends PagedList<T> {
360366
private readonly disposables: DisposableStore;
361367

362368
private _useAltAsMultipleSelectionModifier: boolean;
369+
private horizontalScrolling: boolean | undefined;
363370

364371
constructor(
365372
user: string,
@@ -389,6 +396,7 @@ export class WorkbenchPagedList<T> extends PagedList<T> {
389396

390397
this.contextKeyService = createScopedContextKeyService(contextKeyService, this);
391398
this.configurationService = configurationService;
399+
this.horizontalScrolling = options.horizontalScrolling;
392400

393401
const listSupportsMultiSelect = WorkbenchListSupportsMultiSelectContextKey.bindTo(this.contextKeyService);
394402
listSupportsMultiSelect.set(!(options.multipleSelectionSupport === false));
@@ -410,6 +418,10 @@ export class WorkbenchPagedList<T> extends PagedList<T> {
410418
if (e.affectsConfiguration(multiSelectModifierSettingKey)) {
411419
this._useAltAsMultipleSelectionModifier = useAltAsMultipleSelectionModifier(this.configurationService);
412420
}
421+
if (e.affectsConfiguration(horizontalScrollingKey) && this.horizontalScrolling === undefined) {
422+
const horizontalScrolling = this.configurationService.getValue<boolean>(horizontalScrollingKey);
423+
this.updateOptions({ horizontalScrolling });
424+
}
413425
}));
414426
}
415427

@@ -608,7 +620,7 @@ export class WorkbenchObjectTree<T extends NonNullable<any>, TFilterData = void>
608620
const { options: treeOptions, getAutomaticKeyboardNavigation, disposable } = workbenchTreeDataPreamble<T, TFilterData, IWorkbenchObjectTreeOptions<T, TFilterData>>(container, options, contextKeyService, configurationService, keybindingService, accessibilityService);
609621
super(user, container, delegate, renderers, treeOptions);
610622
this.disposables.add(disposable);
611-
this.internals = new WorkbenchTreeInternals(this, treeOptions, getAutomaticKeyboardNavigation, options.overrideStyles, contextKeyService, listService, themeService, configurationService, accessibilityService);
623+
this.internals = new WorkbenchTreeInternals(this, options, getAutomaticKeyboardNavigation, options.overrideStyles, contextKeyService, listService, themeService, configurationService, accessibilityService);
612624
this.disposables.add(this.internals);
613625
}
614626
}
@@ -643,7 +655,7 @@ export class WorkbenchCompressibleObjectTree<T extends NonNullable<any>, TFilter
643655
const { options: treeOptions, getAutomaticKeyboardNavigation, disposable } = workbenchTreeDataPreamble<T, TFilterData, IWorkbenchCompressibleObjectTreeOptions<T, TFilterData>>(container, options, contextKeyService, configurationService, keybindingService, accessibilityService);
644656
super(user, container, delegate, renderers, treeOptions);
645657
this.disposables.add(disposable);
646-
this.internals = new WorkbenchTreeInternals(this, treeOptions, getAutomaticKeyboardNavigation, options.overrideStyles, contextKeyService, listService, themeService, configurationService, accessibilityService);
658+
this.internals = new WorkbenchTreeInternals(this, options, getAutomaticKeyboardNavigation, options.overrideStyles, contextKeyService, listService, themeService, configurationService, accessibilityService);
647659
this.disposables.add(this.internals);
648660
}
649661

@@ -687,7 +699,7 @@ export class WorkbenchDataTree<TInput, T, TFilterData = void> extends DataTree<T
687699
const { options: treeOptions, getAutomaticKeyboardNavigation, disposable } = workbenchTreeDataPreamble<T, TFilterData, IWorkbenchDataTreeOptions<T, TFilterData>>(container, options, contextKeyService, configurationService, keybindingService, accessibilityService);
688700
super(user, container, delegate, renderers, dataSource, treeOptions);
689701
this.disposables.add(disposable);
690-
this.internals = new WorkbenchTreeInternals(this, treeOptions, getAutomaticKeyboardNavigation, options.overrideStyles, contextKeyService, listService, themeService, configurationService, accessibilityService);
702+
this.internals = new WorkbenchTreeInternals(this, options, getAutomaticKeyboardNavigation, options.overrideStyles, contextKeyService, listService, themeService, configurationService, accessibilityService);
691703
this.disposables.add(this.internals);
692704
}
693705

@@ -731,7 +743,7 @@ export class WorkbenchAsyncDataTree<TInput, T, TFilterData = void> extends Async
731743
const { options: treeOptions, getAutomaticKeyboardNavigation, disposable } = workbenchTreeDataPreamble<T, TFilterData, IWorkbenchAsyncDataTreeOptions<T, TFilterData>>(container, options, contextKeyService, configurationService, keybindingService, accessibilityService);
732744
super(user, container, delegate, renderers, dataSource, treeOptions);
733745
this.disposables.add(disposable);
734-
this.internals = new WorkbenchTreeInternals(this, treeOptions, getAutomaticKeyboardNavigation, options.overrideStyles, contextKeyService, listService, themeService, configurationService, accessibilityService);
746+
this.internals = new WorkbenchTreeInternals(this, options, getAutomaticKeyboardNavigation, options.overrideStyles, contextKeyService, listService, themeService, configurationService, accessibilityService);
735747
this.disposables.add(this.internals);
736748
}
737749

@@ -773,7 +785,7 @@ export class WorkbenchCompressibleAsyncDataTree<TInput, T, TFilterData = void> e
773785
const { options: treeOptions, getAutomaticKeyboardNavigation, disposable } = workbenchTreeDataPreamble<T, TFilterData, IWorkbenchCompressibleAsyncDataTreeOptions<T, TFilterData>>(container, options, contextKeyService, configurationService, keybindingService, accessibilityService);
774786
super(user, container, virtualDelegate, compressionDelegate, renderers, dataSource, treeOptions);
775787
this.disposables.add(disposable);
776-
this.internals = new WorkbenchTreeInternals(this, treeOptions, getAutomaticKeyboardNavigation, options.overrideStyles, contextKeyService, listService, themeService, configurationService, accessibilityService);
788+
this.internals = new WorkbenchTreeInternals(this, options, getAutomaticKeyboardNavigation, options.overrideStyles, contextKeyService, listService, themeService, configurationService, accessibilityService);
777789
this.disposables.add(this.internals);
778790
}
779791
}
@@ -806,7 +818,7 @@ function workbenchTreeDataPreamble<T, TFilterData, TOptions extends IAbstractTre
806818

807819
const accessibilityOn = accessibilityService.isScreenReaderOptimized();
808820
const keyboardNavigation = accessibilityOn ? 'simple' : configurationService.getValue<string>(keyboardNavigationSettingKey);
809-
const horizontalScrolling = typeof options.horizontalScrolling !== 'undefined' ? options.horizontalScrolling : configurationService.getValue<boolean>(horizontalScrollingKey);
821+
const horizontalScrolling = options.horizontalScrolling !== undefined ? options.horizontalScrolling : configurationService.getValue<boolean>(horizontalScrollingKey);
810822
const openOnSingleClick = useSingleClickToOpen(configurationService);
811823
const [workbenchListOptions, disposable] = toWorkbenchListOptions(options, configurationService, keybindingService);
812824
const additionalScrollHeight = options.additionalScrollHeight;
@@ -896,33 +908,37 @@ class WorkbenchTreeInternals<TInput, T, TFilterData> {
896908
this.hasSelectionOrFocus.set(selection.length > 0 || focus.length > 0);
897909
}),
898910
configurationService.onDidChangeConfiguration(e => {
899-
let options: any = {};
911+
let newOptions: any = {};
900912
if (e.affectsConfiguration(openModeSettingKey)) {
901-
options = { ...options, openOnSingleClick: useSingleClickToOpen(configurationService) };
913+
newOptions = { ...newOptions, openOnSingleClick: useSingleClickToOpen(configurationService) };
902914
}
903915
if (e.affectsConfiguration(multiSelectModifierSettingKey)) {
904916
this._useAltAsMultipleSelectionModifier = useAltAsMultipleSelectionModifier(configurationService);
905917
}
906918
if (e.affectsConfiguration(treeIndentKey)) {
907919
const indent = configurationService.getValue<number>(treeIndentKey);
908-
options = { ...options, indent };
920+
newOptions = { ...newOptions, indent };
909921
}
910922
if (e.affectsConfiguration(treeRenderIndentGuidesKey)) {
911923
const renderIndentGuides = configurationService.getValue<RenderIndentGuides>(treeRenderIndentGuidesKey);
912-
options = { ...options, renderIndentGuides };
924+
newOptions = { ...newOptions, renderIndentGuides };
913925
}
914926
if (e.affectsConfiguration(listSmoothScrolling)) {
915927
const smoothScrolling = configurationService.getValue<boolean>(listSmoothScrolling);
916-
options = { ...options, smoothScrolling };
928+
newOptions = { ...newOptions, smoothScrolling };
917929
}
918930
if (e.affectsConfiguration(keyboardNavigationSettingKey)) {
919931
updateKeyboardNavigation();
920932
}
921933
if (e.affectsConfiguration(automaticKeyboardNavigationSettingKey)) {
922-
options = { ...options, automaticKeyboardNavigation: getAutomaticKeyboardNavigation() };
934+
newOptions = { ...newOptions, automaticKeyboardNavigation: getAutomaticKeyboardNavigation() };
935+
}
936+
if (e.affectsConfiguration(horizontalScrollingKey) && options.horizontalScrolling === undefined) {
937+
const horizontalScrolling = configurationService.getValue<boolean>(horizontalScrollingKey);
938+
newOptions = { ...newOptions, horizontalScrolling };
923939
}
924-
if (Object.keys(options).length > 0) {
925-
tree.updateOptions(options);
940+
if (Object.keys(newOptions).length > 0) {
941+
tree.updateOptions(newOptions);
926942
}
927943
}),
928944
this.contextKeyService.onDidChangeContext(e => {

0 commit comments

Comments
 (0)