Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix empty files tree #3307

Merged
merged 1 commit into from
Feb 10, 2022
Merged
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
6 changes: 6 additions & 0 deletions src/view/prChangesTreeDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ export class PullRequestChangesTreeDataProvider extends vscode.Disposable implem
reviewModel: ReviewModel,
shouldReveal: boolean,
) {
if (this._pullRequestManagerMap.has(pullRequestManager)) {
const existingNode = this._pullRequestManagerMap.get(pullRequestManager);
if (existingNode && (existingNode.pullRequestModel === pullRequestModel)) {
return;
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Previously, the pull request node would get re-added to the tree view, but the old node wouldn't get disposed of. This led to tree nodes that didn't exist in the tree any more trying to refresh themselves, which in turn let to exceptions that prevented the tree from completing it's refresh.

const node: RepositoryChangesNode = new RepositoryChangesNode(
this,
pullRequestModel,
Expand Down
5 changes: 3 additions & 2 deletions src/view/treeNodes/commitsCategoryNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ export class CommitsNode extends TreeNode implements vscode.TreeItem {
this._folderRepoManager = reposManager;
this.collapsibleState = vscode.TreeItemCollapsibleState.Collapsed;

this._pr.onDidChangeReviewThreads(() => this.refresh(this));
this._pr.onDidChangeComments(() => this.refresh(this));
this.childrenDisposables = [];
this.childrenDisposables.push(this._pr.onDidChangeReviewThreads(() => this.refresh(this)));
this.childrenDisposables.push(this._pr.onDidChangeComments(() => this.refresh(this)));
}

getTreeItem(): vscode.TreeItem {
Expand Down
9 changes: 0 additions & 9 deletions src/view/treeNodes/fileChangeNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,6 @@ export class FileChangeNode extends TreeNode implements vscode.TreeItem {
}),
);

this.childrenDisposables.push(this.pullRequest.onDidChangeComments(() => {
this.updateShowOptions();
this.refresh(this);
}));

this.childrenDisposables.push(this.pullRequest.onDidChangeReviewThreads(() => {
this.updateShowOptions();
this.refresh(this);
}));

this.accessibilityInformation = { label: `View diffs and comments for file ${this.label}`, role: 'link' };
}
Expand Down
9 changes: 5 additions & 4 deletions src/view/treeNodes/filesCategoryNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ export class FilesCategoryNode extends TreeNode implements vscode.TreeItem {
constructor(
public parent: TreeNodeParent,
private _reviewModel: ReviewModel,
private _pullRequestModel: PullRequestModel
_pullRequestModel: PullRequestModel
) {
super();
this.collapsibleState = vscode.TreeItemCollapsibleState.Expanded;
this._reviewModel.onDidChangeLocalFileChanges(() => this.refresh(this));
this._pullRequestModel.onDidChangeReviewThreads(() => this.refresh(this));
this._pullRequestModel.onDidChangeComments(() => this.refresh(this));
this.childrenDisposables = [];
this.childrenDisposables.push(this._reviewModel.onDidChangeLocalFileChanges(() => this.refresh(this)));
this.childrenDisposables.push(_pullRequestModel.onDidChangeReviewThreads(() => this.refresh(this)));
this.childrenDisposables.push(_pullRequestModel.onDidChangeComments(() => this.refresh(this)));
}

getTreeItem(): vscode.TreeItem {
Expand Down