From e2bc0e116f8637b4edfa8cb28ebb346995df55a7 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Mon, 12 Mar 2018 16:05:31 +0100 Subject: [PATCH] workbench.tree.horizontalScrolling setting --- src/vs/platform/list/browser/listService.ts | 27 ++++++++++++------- .../relauncher.contribution.ts | 8 ++++++ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/vs/platform/list/browser/listService.ts b/src/vs/platform/list/browser/listService.ts index eb3980531c4..24a177ae1bc 100644 --- a/src/vs/platform/list/browser/listService.ts +++ b/src/vs/platform/list/browser/listService.ts @@ -106,6 +106,7 @@ function createScopedContextKeyService(contextKeyService: IContextKeyService, wi export const multiSelectModifierSettingKey = 'workbench.list.multiSelectModifier'; export const openModeSettingKey = 'workbench.list.openMode'; +export const horizontalScrollingKey = 'workbench.tree.horizontalScrolling'; function useAltAsMultipleSelectionModifier(configurationService: IConfigurationService): boolean { return configurationService.getValue(multiSelectModifierSettingKey) === 'alt'; @@ -282,7 +283,7 @@ export class WorkbenchTree extends Tree { readonly contextKeyService: IContextKeyService; - protected disposables: IDisposable[] = []; + protected disposables: IDisposable[]; private listDoubleSelection: IContextKey; private listMultiSelection: IContextKey; @@ -298,10 +299,15 @@ export class WorkbenchTree extends Tree { @IListService listService: IListService, @IThemeService themeService: IThemeService, @IInstantiationService instantiationService: IInstantiationService, - @IConfigurationService private configurationService: IConfigurationService + @IConfigurationService configurationService: IConfigurationService ) { - super(container, handleTreeController(configuration, instantiationService), { horizontalScrollMode: ScrollbarVisibility.Auto, keyboardSupport: false, ...options }); + const config = handleTreeController(configuration, instantiationService); + const horizontalScrollMode = configurationService.getValue(horizontalScrollingKey) ? ScrollbarVisibility.Auto : ScrollbarVisibility.Hidden; + const opts = { horizontalScrollMode, keyboardSupport: false, ...options }; + super(container, config, opts); + + this.disposables = []; this.contextKeyService = createScopedContextKeyService(contextKeyService, this); this.listDoubleSelection = WorkbenchListDoubleSelection.bindTo(this.contextKeyService); this.listMultiSelection = WorkbenchListMultiSelection.bindTo(this.contextKeyService); @@ -315,23 +321,19 @@ export class WorkbenchTree extends Tree { attachListStyler(this, themeService) ); - this.registerListeners(); - } - - private registerListeners(): void { this.disposables.push(this.onDidChangeSelection(() => { const selection = this.getSelection(); this.listDoubleSelection.set(selection && selection.length === 2); this.listMultiSelection.set(selection && selection.length > 1); })); - this.disposables.push(this.configurationService.onDidChangeConfiguration(e => { + this.disposables.push(configurationService.onDidChangeConfiguration(e => { if (e.affectsConfiguration(openModeSettingKey)) { - this._openOnSingleClick = useSingleClickToOpen(this.configurationService); + this._openOnSingleClick = useSingleClickToOpen(configurationService); } if (e.affectsConfiguration(multiSelectModifierSettingKey)) { - this._useAltAsMultipleSelectionModifier = useAltAsMultipleSelectionModifier(this.configurationService); + this._useAltAsMultipleSelectionModifier = useAltAsMultipleSelectionModifier(configurationService); } })); } @@ -516,6 +518,11 @@ configurationRegistry.registerConfiguration({ key: 'openModeModifier', comment: ['`singleClick` and `doubleClick` refers to a value the setting can take and should not be localized.'] }, "Controls how to open items in trees and lists using the mouse (if supported). Set to `singleClick` to open items with a single mouse click and `doubleClick` to only open via mouse double click. For parents with children in trees, this setting will control if a single click expands the parent or a double click. Note that some trees and lists might choose to ignore this setting if it is not applicable. ") + }, + [horizontalScrollingKey]: { + 'type': 'boolean', + 'default': false, + 'description': localize('horizontalScrolling setting', "Controls whether trees support horizontal scrolling in the workbench.") } } }); diff --git a/src/vs/workbench/parts/relauncher/electron-browser/relauncher.contribution.ts b/src/vs/workbench/parts/relauncher/electron-browser/relauncher.contribution.ts index 9f5b18c4111..382ae5cb8fc 100644 --- a/src/vs/workbench/parts/relauncher/electron-browser/relauncher.contribution.ts +++ b/src/vs/workbench/parts/relauncher/electron-browser/relauncher.contribution.ts @@ -25,6 +25,7 @@ interface IConfiguration extends IWindowsConfiguration { update: { channel: string; }; telemetry: { enableCrashReporter: boolean }; keyboard: { touchbar: { enabled: boolean } }; + workbench: { tree: { horizontalScrolling: boolean } }; } export class SettingsChangeRelauncher implements IWorkbenchContribution { @@ -36,6 +37,7 @@ export class SettingsChangeRelauncher implements IWorkbenchContribution { private updateChannel: string; private enableCrashReporter: boolean; private touchbarEnabled: boolean; + private treeHorizontalScrolling: boolean; private firstFolderResource: URI; private extensionHostRestarter: RunOnceScheduler; @@ -99,6 +101,12 @@ export class SettingsChangeRelauncher implements IWorkbenchContribution { changed = true; } + // Tree horizontal scrolling support + if (config.workbench && config.workbench.tree && typeof config.workbench.tree.horizontalScrolling === 'boolean' && config.workbench.tree.horizontalScrolling !== this.treeHorizontalScrolling) { + this.treeHorizontalScrolling = config.workbench.tree.horizontalScrolling; + changed = true; + } + // Notify only when changed and we are the focused window (avoids notification spam across windows) if (notify && changed) { this.doConfirm(