Skip to content

Commit

Permalink
Treeview reveal 'select/focus' option problem when trying to keep foc…
Browse files Browse the repository at this point in the history
…us in original panel. (microsoft#178044)

Fixes microsoft#174811
  • Loading branch information
alexr00 authored Mar 22, 2023
1 parent 37dcb72 commit ae32037
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/vs/workbench/api/browser/mainThreadTreeViews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ export class MainThreadTreeViews extends Disposable implements MainThreadTreeVie
if (select) {
treeView.setSelection([item]);
}
if (focus) {
if (focus === false) {
treeView.setFocus();
} else if (focus) {
treeView.setFocus(item);
}
let itemsToExpand = [item];
Expand Down
10 changes: 7 additions & 3 deletions src/vs/workbench/browser/parts/views/treeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -917,10 +917,14 @@ abstract class AbstractTreeView extends Disposable implements ITreeView {
return this.tree?.getSelection() ?? [];
}

setFocus(item: ITreeItem): void {
setFocus(item?: ITreeItem): void {
if (this.tree) {
this.focus(true, item);
this.tree.setFocus([item]);
if (item) {
this.focus(true, item);
this.tree.setFocus([item]);
} else {
this.tree.setFocus([]);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/common/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ export interface ITreeView extends IDisposable {

getSelection(): ITreeItem[];

setFocus(item: ITreeItem): void;
setFocus(item?: ITreeItem): void;

show(container: any): void;
}
Expand Down

0 comments on commit ae32037

Please sign in to comment.