Skip to content

Commit 7c91227

Browse files
committed
tree.select should watch for expandOnlyOnTwistieClick
1 parent 13915ba commit 7c91227

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,14 @@ export class AsyncDataTree<TInput, T, TFilterData = void> implements IDisposable
326326

327327
get filterOnType(): boolean { return this.tree.filterOnType; }
328328
get openOnSingleClick(): boolean { return this.tree.openOnSingleClick; }
329+
get expandOnlyOnTwistieClick(): boolean | ((e: T) => boolean) {
330+
if (typeof this.tree.expandOnlyOnTwistieClick === 'boolean') {
331+
return this.tree.expandOnlyOnTwistieClick;
332+
}
333+
334+
const fn = this.tree.expandOnlyOnTwistieClick;
335+
return element => fn(this.nodes.get((element === this.root.element ? null : element) as T) || null);
336+
}
329337

330338
get onDidDispose(): Event<void> { return this.tree.onDidDispose; }
331339

src/vs/workbench/browser/actions/listCommands.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,17 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
603603
const focus = list.getFocus();
604604

605605
if (focus.length > 0) {
606-
list.toggleCollapsed(focus[0]);
606+
let toggleCollapsed = true;
607+
608+
if (list.expandOnlyOnTwistieClick === true) {
609+
toggleCollapsed = false;
610+
} else if (typeof list.expandOnlyOnTwistieClick !== 'boolean' && list.expandOnlyOnTwistieClick(focus[0])) {
611+
toggleCollapsed = false;
612+
}
613+
614+
if (toggleCollapsed) {
615+
list.toggleCollapsed(focus[0]);
616+
}
607617
}
608618

609619
list.setSelection(focus, fakeKeyboardEvent);

0 commit comments

Comments
 (0)