Skip to content

Commit d2fd388

Browse files
author
Benjamin Pasero
committed
list/tree - control open behaviour in one place and prefer to open on mouse down vs mouse up
1 parent 11701fd commit d2fd388

19 files changed

Lines changed: 50 additions & 38 deletions

File tree

src/vs/base/parts/tree/browser/treeDefaults.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export class DefaultController implements _.IController {
8888

8989
private options: IControllerOptions;
9090

91-
constructor(options: IControllerOptions = { clickBehavior: ClickBehavior.ON_MOUSE_UP, keyboardSupport: true, openMode: OpenMode.SINGLE_CLICK }) {
91+
constructor(options: IControllerOptions = { clickBehavior: ClickBehavior.ON_MOUSE_DOWN, keyboardSupport: true, openMode: OpenMode.SINGLE_CLICK }) {
9292
this.options = options;
9393

9494
this.downKeyBindingDispatcher = new KeybindingDispatcher();

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ function handleListControllers<T>(options: IListOptions<T>, configurationService
152152

153153
function handleTreeController(configuration: ITreeConfiguration, instantiationService: IInstantiationService): ITreeConfiguration {
154154
if (!configuration.controller) {
155-
configuration.controller = instantiationService.createInstance(WorkbenchTreeController, { clickBehavior: ClickBehavior.ON_MOUSE_UP });
155+
configuration.controller = instantiationService.createInstance(WorkbenchTreeController, {});
156156
}
157157

158158
return configuration;
@@ -176,7 +176,7 @@ export class WorkbenchList<T> extends List<T> {
176176
@IThemeService themeService: IThemeService,
177177
@IConfigurationService private configurationService: IConfigurationService
178178
) {
179-
super(container, delegate, renderers, mixin(handleListControllers(options, configurationService), { keyboardSupport: false } as IListOptions<any>, false));
179+
super(container, delegate, renderers, mixin(handleListControllers(options, configurationService), { keyboardSupport: false, selectOnMouseDown: true } as IListOptions<any>, false));
180180

181181
this.contextKeyService = createScopedContextKeyService(contextKeyService, this);
182182
this.listDoubleSelection = WorkbenchListDoubleSelection.bindTo(this.contextKeyService);
@@ -224,7 +224,7 @@ export class WorkbenchPagedList<T> extends PagedList<T> {
224224
@IThemeService themeService: IThemeService,
225225
@IConfigurationService private configurationService: IConfigurationService
226226
) {
227-
super(container, delegate, renderers, mixin(handleListControllers(options, configurationService), { keyboardSupport: false } as IListOptions<any>, false));
227+
super(container, delegate, renderers, mixin(handleListControllers(options, configurationService), { keyboardSupport: false, selectOnMouseDown: true } as IListOptions<any>, false));
228228

229229
this.contextKeyService = createScopedContextKeyService(contextKeyService, this);
230230

@@ -324,6 +324,18 @@ export class WorkbenchTree extends Tree {
324324
}
325325
}
326326

327+
function massageControllerOptions(options: IControllerOptions): IControllerOptions {
328+
if (typeof options.keyboardSupport !== 'boolean') {
329+
options.keyboardSupport = false;
330+
}
331+
332+
if (typeof options.clickBehavior !== 'number') {
333+
options.clickBehavior = ClickBehavior.ON_MOUSE_DOWN;
334+
}
335+
336+
return options;
337+
}
338+
327339
export class WorkbenchTreeController extends DefaultController {
328340

329341
protected disposables: IDisposable[] = [];
@@ -332,7 +344,7 @@ export class WorkbenchTreeController extends DefaultController {
332344
options: IControllerOptions,
333345
@IConfigurationService private configurationService: IConfigurationService
334346
) {
335-
super(options);
347+
super(massageControllerOptions(options));
336348

337349
// if the open mode is not set, we configure it based on settings
338350
if (isUndefinedOrNull(options.openMode)) {

src/vs/workbench/browser/parts/views/treeView.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { IAction, IActionItem, ActionRunner } from 'vs/base/common/actions';
1414
import { IMessageService } from 'vs/platform/message/common/message';
1515
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
1616
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
17-
import { ClickBehavior } from 'vs/base/parts/tree/browser/treeDefaults';
1817
import { IMenuService, MenuId, MenuItemAction } from 'vs/platform/actions/common/actions';
1918
import { IThemeService, LIGHT } from 'vs/platform/theme/common/themeService';
2019
import { fillInActions, ContextAwareMenuItemActionItem } from 'vs/platform/actions/browser/menuItemActionItem';
@@ -419,7 +418,7 @@ class TreeController extends WorkbenchTreeController {
419418
@IKeybindingService private _keybindingService: IKeybindingService,
420419
@IConfigurationService configurationService: IConfigurationService
421420
) {
422-
super({ clickBehavior: ClickBehavior.ON_MOUSE_UP /* do not change to not break DND */, keyboardSupport: false }, configurationService);
421+
super({}, configurationService);
423422
}
424423

425424
public onContextMenu(tree: ITree, node: ITreeItem, event: ContextMenuEvent): boolean {

src/vs/workbench/parts/debug/electron-browser/baseDebugView.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
1515
import { once } from 'vs/base/common/functional';
1616
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
1717
import { IMenuService, MenuId, IMenu } from 'vs/platform/actions/common/actions';
18-
import { ClickBehavior, IControllerOptions } from 'vs/base/parts/tree/browser/treeDefaults';
18+
import { IControllerOptions } from 'vs/base/parts/tree/browser/treeDefaults';
1919
import { fillInActions } from 'vs/platform/actions/browser/menuItemActionItem';
2020
import { KeyCode } from 'vs/base/common/keyCodes';
2121
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
@@ -192,8 +192,6 @@ export function renderRenameBox(debugService: IDebugService, contextViewService:
192192
}));
193193
}
194194

195-
export const DefaultDebugControllerOptions: IControllerOptions = { clickBehavior: ClickBehavior.ON_MOUSE_UP, keyboardSupport: false };
196-
197195
export class BaseDebugController extends WorkbenchTreeController {
198196

199197
private contributedContextMenu: IMenu;

src/vs/workbench/parts/debug/electron-browser/breakpointsView.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export class BreakpointsView extends ViewsViewletPanel {
7272
], {
7373
identityProvider: element => element.getId(),
7474
multipleSelectionSupport: false
75-
});
75+
}) as WorkbenchList<IEnablement>;
7676

7777
CONTEXT_BREAKPOINTS_FOCUSED.bindTo(this.list.contextKeyService);
7878

src/vs/workbench/parts/debug/electron-browser/callStackView.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView
1515
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
1616
import { MenuId } from 'vs/platform/actions/common/actions';
1717
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
18-
import { BaseDebugController, twistiePixels, renderViewTree, DefaultDebugControllerOptions } from 'vs/workbench/parts/debug/electron-browser/baseDebugView';
18+
import { BaseDebugController, twistiePixels, renderViewTree } from 'vs/workbench/parts/debug/electron-browser/baseDebugView';
1919
import { ITree, IActionProvider, IDataSource, IRenderer, IAccessibilityProvider } from 'vs/base/parts/tree/browser/tree';
2020
import { IAction, IActionItem } from 'vs/base/common/actions';
2121
import { RestartAction, StopAction, ContinueAction, StepOverAction, StepIntoAction, StepOutAction, PauseAction, RestartFrameAction } from 'vs/workbench/parts/debug/browser/debugActions';
@@ -92,7 +92,7 @@ export class CallStackView extends TreeViewsViewletPanel {
9292
dom.addClass(container, 'debug-call-stack');
9393
this.treeContainer = renderViewTree(container);
9494
const actionProvider = new CallStackActionProvider(this.debugService, this.keybindingService);
95-
const controller = this.instantiationService.createInstance(CallStackController, actionProvider, MenuId.DebugCallStackContext, DefaultDebugControllerOptions);
95+
const controller = this.instantiationService.createInstance(CallStackController, actionProvider, MenuId.DebugCallStackContext, {});
9696

9797
this.tree = this.instantiationService.createInstance(WorkbenchTree, this.treeContainer, {
9898
dataSource: new CallStackDataSource(),

src/vs/workbench/parts/debug/electron-browser/debugHover.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { ScrollbarVisibility } from 'vs/base/common/scrollable';
1111
import * as dom from 'vs/base/browser/dom';
1212
import { ITree } from 'vs/base/parts/tree/browser/tree';
1313
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
14-
import { DefaultController, ICancelableEvent, ClickBehavior, OpenMode } from 'vs/base/parts/tree/browser/treeDefaults';
14+
import { ICancelableEvent, OpenMode } from 'vs/base/parts/tree/browser/treeDefaults';
1515
import { IConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions';
1616
import { Position } from 'vs/editor/common/core/position';
1717
import { Range } from 'vs/editor/common/core/range';
@@ -25,7 +25,8 @@ import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableEle
2525
import { attachStylerCallback } from 'vs/platform/theme/common/styler';
2626
import { IThemeService } from 'vs/platform/theme/common/themeService';
2727
import { editorHoverBackground, editorHoverBorder } from 'vs/platform/theme/common/colorRegistry';
28-
import { WorkbenchTree } from 'vs/platform/list/browser/listService';
28+
import { WorkbenchTree, WorkbenchTreeController } from 'vs/platform/list/browser/listService';
29+
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
2930

3031
const $ = dom.$;
3132
const MAX_ELEMENTS_SHOWN = 18;
@@ -71,7 +72,7 @@ export class DebugHoverWidget implements IContentWidget {
7172
this.tree = this.instantiationService.createInstance(WorkbenchTree, this.treeContainer, {
7273
dataSource: new VariablesDataSource(),
7374
renderer: this.instantiationService.createInstance(VariablesHoverRenderer),
74-
controller: new DebugHoverController(this.editor)
75+
controller: this.instantiationService.createInstance(DebugHoverController, this.editor)
7576
}, {
7677
indentPixels: 6,
7778
twistiePixels: 15,
@@ -333,10 +334,13 @@ export class DebugHoverWidget implements IContentWidget {
333334
}
334335
}
335336

336-
class DebugHoverController extends DefaultController {
337+
class DebugHoverController extends WorkbenchTreeController {
337338

338-
constructor(private editor: ICodeEditor) {
339-
super({ clickBehavior: ClickBehavior.ON_MOUSE_UP, keyboardSupport: false, openMode: OpenMode.SINGLE_CLICK });
339+
constructor(
340+
private editor: ICodeEditor,
341+
@IConfigurationService configurationService: IConfigurationService
342+
) {
343+
super({ openMode: OpenMode.SINGLE_CLICK }, configurationService);
340344
}
341345

342346
protected onLeftClick(tree: ITree, element: any, eventish: ICancelableEvent, origin = 'mouse'): boolean {

src/vs/workbench/parts/debug/electron-browser/repl.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
4444
import { WorkbenchTree } from 'vs/platform/list/browser/listService';
4545
import { memoize } from 'vs/base/common/decorators';
4646
import { dispose } from 'vs/base/common/lifecycle';
47-
import { ClickBehavior, OpenMode } from 'vs/base/parts/tree/browser/treeDefaults';
47+
import { OpenMode } from 'vs/base/parts/tree/browser/treeDefaults';
4848

4949
const $ = dom.$;
5050

@@ -135,7 +135,7 @@ export class Repl extends Panel implements IPrivateReplService {
135135
this.createReplInput(this.container);
136136

137137
this.renderer = this.instantiationService.createInstance(ReplExpressionsRenderer);
138-
const controller = this.instantiationService.createInstance(ReplExpressionsController, new ReplExpressionsActionProvider(this.instantiationService), MenuId.DebugConsoleContext, { clickBehavior: ClickBehavior.ON_MOUSE_UP, keyboardSupport: false, openMode: OpenMode.SINGLE_CLICK });
138+
const controller = this.instantiationService.createInstance(ReplExpressionsController, new ReplExpressionsActionProvider(this.instantiationService), MenuId.DebugConsoleContext, { openMode: OpenMode.SINGLE_CLICK });
139139
controller.toFocusOnClick = this.replInput;
140140

141141
this.tree = this.instantiationService.createInstance(WorkbenchTree, this.treeContainer, {

src/vs/workbench/parts/debug/electron-browser/variablesView.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { ViewModel } from 'vs/workbench/parts/debug/common/debugViewModel';
2828
import { equalsIgnoreCase } from 'vs/base/common/strings';
2929
import { IMouseEvent } from 'vs/base/browser/mouseEvent';
3030
import { WorkbenchTree } from 'vs/platform/list/browser/listService';
31-
import { ClickBehavior, OpenMode } from 'vs/base/parts/tree/browser/treeDefaults';
31+
import { OpenMode } from 'vs/base/parts/tree/browser/treeDefaults';
3232

3333
const $ = dom.$;
3434

@@ -88,7 +88,7 @@ export class VariablesView extends TreeViewsViewletPanel {
8888
dataSource: new VariablesDataSource(),
8989
renderer: this.instantiationService.createInstance(VariablesRenderer),
9090
accessibilityProvider: new VariablesAccessibilityProvider(),
91-
controller: this.instantiationService.createInstance(VariablesController, new VariablesActionProvider(this.debugService, this.keybindingService), MenuId.DebugVariablesContext, { clickBehavior: ClickBehavior.ON_MOUSE_UP, keyboardSupport: false, openMode: OpenMode.SINGLE_CLICK })
91+
controller: this.instantiationService.createInstance(VariablesController, new VariablesActionProvider(this.debugService, this.keybindingService), MenuId.DebugVariablesContext, { openMode: OpenMode.SINGLE_CLICK })
9292
}, {
9393
ariaLabel: nls.localize('variablesAriaTreeLabel', "Debug Variables"),
9494
twistiePixels

src/vs/workbench/parts/debug/electron-browser/watchExpressionsView.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { CopyValueAction } from 'vs/workbench/parts/debug/electron-browser/elect
2626
import { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
2727
import { equalsIgnoreCase } from 'vs/base/common/strings';
2828
import { IMouseEvent, DragMouseEvent } from 'vs/base/browser/mouseEvent';
29-
import { DefaultDragAndDrop, ClickBehavior, OpenMode } from 'vs/base/parts/tree/browser/treeDefaults';
29+
import { DefaultDragAndDrop, OpenMode, ClickBehavior } from 'vs/base/parts/tree/browser/treeDefaults';
3030
import { IVariableTemplateData, renderVariable, renderRenameBox, renderExpressionValue, BaseDebugController, twistiePixels, renderViewTree } from 'vs/workbench/parts/debug/electron-browser/baseDebugView';
3131
import { WorkbenchTree } from 'vs/platform/list/browser/listService';
3232

@@ -65,7 +65,7 @@ export class WatchExpressionsView extends TreeViewsViewletPanel {
6565
dataSource: new WatchExpressionsDataSource(this.debugService),
6666
renderer: this.instantiationService.createInstance(WatchExpressionsRenderer),
6767
accessibilityProvider: new WatchExpressionsAccessibilityProvider(),
68-
controller: this.instantiationService.createInstance(WatchExpressionsController, actionProvider, MenuId.DebugWatchContext, { clickBehavior: ClickBehavior.ON_MOUSE_UP, keyboardSupport: false, openMode: OpenMode.SINGLE_CLICK }),
68+
controller: this.instantiationService.createInstance(WatchExpressionsController, actionProvider, MenuId.DebugWatchContext, { clickBehavior: ClickBehavior.ON_MOUSE_UP /* do not change to not break DND */, openMode: OpenMode.SINGLE_CLICK }),
6969
dnd: new WatchExpressionsDragAndDrop(this.debugService)
7070
}, {
7171
ariaLabel: nls.localize({ comment: ['Debug is a noun in this context, not a verb.'], key: 'watchAriaTreeLabel' }, "Debug Watch Expressions"),

0 commit comments

Comments
 (0)