Skip to content

Commit 8ca062e

Browse files
CopilotdmitrivMS
andauthored
Fix multiple items showing selection in tree when clicking twisties (#276847)
* Initial plan * Fix: Prevent multiple items from having focus in tree when clicking twisties Replace focus instead of merging when splicing nodes with focus trait Co-authored-by: dmitrivMS <[email protected]> * Add test for focus behavior when collapsing/expanding tree nodes Co-authored-by: dmitrivMS <[email protected]> * Revert "Fix: Prevent multiple items from having focus in tree when clicking twisties" This reverts commit 6449075. * Revert "Add test for focus behavior when collapsing/expanding tree nodes" This reverts commit 0c85d5a. * Updates * PR feedback, remove tests * PR feedback --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: dmitrivMS <[email protected]> Co-authored-by: Dmitriy Vasyura <[email protected]>
1 parent 157bd3e commit 8ca062e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/vs/platform/quickinput/browser/tree/quickInputTreeController.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export class QuickInputTreeController extends Disposable {
115115
}
116116
));
117117
this.registerCheckboxStateListeners();
118+
this.registerOnDidChangeFocus();
118119
}
119120

120121
get tree(): WorkbenchObjectTree<IQuickTreeItem, IQuickTreeFilterData> {
@@ -341,6 +342,14 @@ export class QuickInputTreeController extends Disposable {
341342
this._onDidCheckedLeafItemsChange.fire(this.getCheckedLeafItems());
342343
}
343344

345+
registerOnDidChangeFocus() {
346+
// Ensure that selection follows focus
347+
this._register(this._tree.onDidChangeFocus(e => {
348+
const item = this._tree.getFocus().findLast(item => item !== null);
349+
this._tree.setSelection(item ? [item] : [], e.browserEvent);
350+
}));
351+
}
352+
344353
getCheckedLeafItems() {
345354
const lookedAt = new Set<IQuickTreeItem>();
346355
const toLookAt = [...this._tree.getNode().children];

0 commit comments

Comments
 (0)