mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 03:54:24 +01:00
@@ -25,6 +25,7 @@ import { isUndefinedOrNull } from 'vs/base/common/types';
|
||||
import { IEditorOptions } from 'vs/platform/editor/common/editor';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import { createStyleSheet } from 'vs/base/browser/dom';
|
||||
import { ScrollbarVisibility } from 'vs/base/common/scrollable';
|
||||
|
||||
export type ListWidget = List<any> | PagedList<any> | ITree;
|
||||
|
||||
@@ -106,6 +107,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';
|
||||
@@ -330,7 +332,7 @@ export class WorkbenchTree extends Tree {
|
||||
|
||||
readonly contextKeyService: IContextKeyService;
|
||||
|
||||
protected disposables: IDisposable[] = [];
|
||||
protected disposables: IDisposable[];
|
||||
|
||||
private listDoubleSelection: IContextKey<boolean>;
|
||||
private listMultiSelection: IContextKey<boolean>;
|
||||
@@ -346,19 +348,20 @@ 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),
|
||||
// mixin magic:
|
||||
// - define some custom tree options common for all workbench trees
|
||||
// - mixin theme colors from default tree styles right on creation
|
||||
mixin(options, mixin({
|
||||
keyboardSupport: false
|
||||
} as ITreeOptions, computeStyles(themeService.getTheme(), defaultListStyles), false), false)
|
||||
);
|
||||
const config = handleTreeController(configuration, instantiationService);
|
||||
const horizontalScrollMode = configurationService.getValue(horizontalScrollingKey) ? ScrollbarVisibility.Auto : ScrollbarVisibility.Hidden;
|
||||
const opts = {
|
||||
horizontalScrollMode,
|
||||
keyboardSupport: false,
|
||||
...computeStyles(themeService.getTheme(), defaultListStyles),
|
||||
...options
|
||||
};
|
||||
|
||||
super(container, config, opts);
|
||||
|
||||
this.disposables = [];
|
||||
this.contextKeyService = createScopedContextKeyService(contextKeyService, this);
|
||||
this.listDoubleSelection = WorkbenchListDoubleSelection.bindTo(this.contextKeyService);
|
||||
this.listMultiSelection = WorkbenchListMultiSelection.bindTo(this.contextKeyService);
|
||||
@@ -372,23 +375,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);
|
||||
}
|
||||
}));
|
||||
}
|
||||
@@ -573,6 +572,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.")
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user