Skip to content

Commit

Permalink
fix a couple of list/tree issues to enable testing
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Jan 30, 2018
1 parent 5b8d394 commit e93f74b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/vs/editor/contrib/referenceSearch/referencesWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ class Controller extends WorkbenchTreeController {
}

var result = super.onClick(tree, element, event);
if (event.ctrlKey || event.metaKey || event.altKey) {
var openToSide = event.ctrlKey || event.metaKey || event.altKey;
if (openToSide && (isDoubleClick || this.openOnSingleClick)) {
this._onDidOpenToSide.fire(element);
} else if (isDoubleClick) {
this._onDidSelect.fire(element);
Expand Down
17 changes: 13 additions & 4 deletions src/vs/platform/list/browser/listService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { ITree, ITreeConfiguration, ITreeOptions } from 'vs/base/parts/tree/browser/tree';
import { List, IListOptions, isSelectionRangeChangeEvent, isSelectionSingleChangeEvent, IMultipleSelectionController, IOpenController } from 'vs/base/browser/ui/list/listWidget';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { createDecorator, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IDisposable, toDisposable, combinedDisposable, dispose, Disposable } from 'vs/base/common/lifecycle';
import { IContextKeyService, IContextKey, RawContextKey, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { PagedList, IPagedRenderer } from 'vs/base/browser/ui/list/listPaging';
Expand All @@ -20,7 +20,7 @@ import { mixin } from 'vs/base/common/objects';
import { localize } from 'vs/nls';
import { Registry } from 'vs/platform/registry/common/platform';
import { Extensions as ConfigurationExtensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry';
import { DefaultController, IControllerOptions, OpenMode } from 'vs/base/parts/tree/browser/treeDefaults';
import { DefaultController, IControllerOptions, OpenMode, ClickBehavior } from 'vs/base/parts/tree/browser/treeDefaults';
import { isUndefinedOrNull } from 'vs/base/common/types';
import { IEditorOptions } from 'vs/platform/editor/common/editor';
import Event, { Emitter } from 'vs/base/common/event';
Expand Down Expand Up @@ -141,7 +141,7 @@ class OpenController implements IOpenController {
}

function handleListControllers<T>(options: IListOptions<T>, configurationService: IConfigurationService): IListOptions<T> {
if (options.multipleSelectionSupport === true && !options.multipleSelectionController) {
if (options.multipleSelectionSupport !== false && !options.multipleSelectionController) {
options.multipleSelectionController = new MultipleSelectionController(configurationService);
}

Expand All @@ -150,6 +150,14 @@ function handleListControllers<T>(options: IListOptions<T>, configurationService
return options;
}

function handleTreeController(configuration: ITreeConfiguration, instantiationService: IInstantiationService): ITreeConfiguration {
if (!configuration.controller) {
configuration.controller = instantiationService.createInstance(WorkbenchTreeController, { clickBehavior: ClickBehavior.ON_MOUSE_UP });
}

return configuration;
}

export class WorkbenchList<T> extends List<T> {

readonly contextKeyService: IContextKeyService;
Expand Down Expand Up @@ -266,9 +274,10 @@ export class WorkbenchTree extends Tree {
@IContextKeyService contextKeyService: IContextKeyService,
@IListService listService: IListService,
@IThemeService themeService: IThemeService,
@IInstantiationService instantiationService: IInstantiationService,
@IConfigurationService private configurationService: IConfigurationService
) {
super(container, configuration, mixin(options, { keyboardSupport: false } as ITreeOptions, false));
super(container, handleTreeController(configuration, instantiationService), mixin(options, { keyboardSupport: false } as ITreeOptions, false));

this.contextKeyService = createScopedContextKeyService(contextKeyService, this);
this.listDoubleSelection = WorkbenchListDoubleSelection.bindTo(this.contextKeyService);
Expand Down
5 changes: 3 additions & 2 deletions src/vs/workbench/browser/parts/views/viewsViewlet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -773,9 +773,10 @@ export class FileIconThemableWorkbenchTree extends WorkbenchTree {
@IContextKeyService contextKeyService: IContextKeyService,
@IListService listService: IListService,
@IThemeService themeService: IWorkbenchThemeService,
@IConfigurationService configurationService: IConfigurationService
@IConfigurationService configurationService: IConfigurationService,
@IInstantiationService instantiationService: IInstantiationService
) {
super(container, configuration, { ...options, ...{ showTwistie: false, twistiePixels: 12 } }, contextKeyService, listService, themeService, configurationService);
super(container, configuration, { ...options, ...{ showTwistie: false, twistiePixels: 12 } }, contextKeyService, listService, themeService, instantiationService, configurationService);

DOM.addClass(container, 'file-icon-themable-tree');
DOM.addClass(container, 'show-file-icons');
Expand Down

0 comments on commit e93f74b

Please sign in to comment.