Skip to content

Commit 1fdade8

Browse files
authored
TreeView reveal fails to scroll to item when focusing and a different selection exists (microsoft#156572)
Fixes microsoft#152803
1 parent e65cf31 commit 1fdade8

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -496,12 +496,12 @@ abstract class AbstractTreeView extends Disposable implements ITreeView {
496496

497497
protected abstract activate(): void;
498498

499-
focus(reveal: boolean = true): void {
499+
focus(reveal: boolean = true, revealItem?: ITreeItem): void {
500500
if (this.tree && this.root.children && this.root.children.length > 0) {
501501
// Make sure the current selected element is revealed
502-
const selectedElement = this.tree.getSelection()[0];
503-
if (selectedElement && reveal) {
504-
this.tree.reveal(selectedElement, 0.5);
502+
const element = revealItem ?? this.tree.getSelection()[0];
503+
if (element && reveal) {
504+
this.tree.reveal(element, 0.5);
505505
}
506506

507507
// Pass Focus to Viewer
@@ -784,7 +784,7 @@ abstract class AbstractTreeView extends Disposable implements ITreeView {
784784

785785
setFocus(item: ITreeItem): void {
786786
if (this.tree) {
787-
this.focus();
787+
this.focus(true, item);
788788
this.tree.setFocus([item]);
789789
}
790790
}

0 commit comments

Comments
 (0)