Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/view/prChangesTreeDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ export class PullRequestChangesTreeDataProvider extends vscode.Disposable implem
private _comments: Comment[] = [];
private _pullrequest: IPullRequestModel = null;
private _pullRequestManager: IPullRequestManager;
private _view: vscode.TreeView<TreeNode>;

constructor(private context: vscode.ExtensionContext) {
super(() => this.dispose());
this.context.subscriptions.push(vscode.window.createTreeView('prStatus', {
this._view = vscode.window.createTreeView('prStatus', {
treeDataProvider: this,
showCollapseAll: true
}));
});

this.context.subscriptions.push(this._view);
}

refresh() {
Expand All @@ -47,6 +50,9 @@ export class PullRequestChangesTreeDataProvider extends vscode.Disposable implem

this._localFileChanges = fileChanges;
this._onDidChangeTreeData.fire();

// Workaround to expand the tree view
this._view.reveal(this.getChildren()[0]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you get this to work properly? In #750 I did the same thing but if getChildren is called by us and there is no real tree item bind to it, VSCode doesn't know how to expand to that node.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh no, I convinced myself this was working when it wasn't. I thought I had the view set to collapsed and then saw it expand on reload, but I must have always just had it open. Let me see if there's a way to store and reuse the result of getChildren for this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually this seems like the problem:

		if (typeof this.dataProvider.getParent !== 'function') {
			return Promise.reject(new Error(`Required registered TreeDataProvider to implement 'getParent' method to access 'reveal' method`));
		}

I'll try adding a getParent

}

async hide() {
Expand Down
5 changes: 5 additions & 0 deletions src/view/prsTreeDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ export class PullRequestsTreeDataProvider implements vscode.TreeDataProvider<Tre
return node ? this._onDidChangeTreeData.fire(node) : this._onDidChangeTreeData.fire();
}

reveal(): void {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤞 #750 introduced a similar logic and has cache for tree items in Pull Request Changes View.

// Expand the tree view
this._view.reveal(this.getChildren()[0]);
}

getTreeItem(element: TreeNode): vscode.TreeItem {
return element.getTreeItem();
}
Expand Down
1 change: 1 addition & 0 deletions src/view/reviewManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export class ReviewManager implements vscode.DecorationProvider {
}));

this._prsTreeDataProvider = new PullRequestsTreeDataProvider(onShouldReload, _prManager, this._telemetry);
this._prsTreeDataProvider.reveal();
this._disposables.push(this._prsTreeDataProvider);
this._disposables.push(vscode.window.registerDecorationProvider(this));

Expand Down