diff --git a/src/test/view/reviewCommentController.test.ts b/src/test/view/reviewCommentController.test.ts index 12e7e87a32..6df4fccbc0 100644 --- a/src/test/view/reviewCommentController.test.ts +++ b/src/test/view/reviewCommentController.test.ts @@ -188,6 +188,28 @@ describe('ReviewCommentController', function () { }; } + it('uses unique comment controller IDs for pull requests in different repositories', function () { + const reviewModel = new ReviewModel(); + const firstController = new TestReviewCommentController(reviewManager, manager, repository, reviewModel, gitApiImpl, telemetry); + const otherRemote = new GitHubRemote('test', 'https://github.com/github/other.git', new Protocol('https://github.com/github/other.git'), GitHubServerType.GitHubDotCom); + const otherGitHubRepo = new MockGitHubRepository(otherRemote, credentialStore, telemetry, sinon); + const otherPullRequest = new PullRequestModel( + credentialStore, + telemetry, + otherGitHubRepo, + otherRemote, + convertRESTPullRequestToRawPullRequest(new PullRequestBuilder().build(), otherGitHubRepo), + ); + manager.activePullRequest = otherPullRequest; + const secondController = new TestReviewCommentController(reviewManager, manager, repository, reviewModel, gitApiImpl, telemetry); + + assert.strictEqual(firstController.commentController.id, `${ReviewCommentController.PREFIX}-${remote.owner}-${remote.repositoryName}-${activePullRequest.number}`); + assert.strictEqual(secondController.commentController.id, `${ReviewCommentController.PREFIX}-${otherRemote.owner}-${otherRemote.repositoryName}-${otherPullRequest.number}`); + assert.notStrictEqual(firstController.commentController.id, secondController.commentController.id); + firstController.dispose(); + secondController.dispose(); + }); + describe('initializes workspace thread data', async function () { const fileName = 'data/products.json'; const uri = vscode.Uri.parse(`${repository.rootUri.toString()}/${fileName}`); diff --git a/src/view/reviewCommentController.ts b/src/view/reviewCommentController.ts index 36c0641567..81c4d0df4c 100644 --- a/src/view/reviewCommentController.ts +++ b/src/view/reviewCommentController.ts @@ -74,7 +74,7 @@ export class ReviewCommentController extends CommentControllerBase implements Co super(folderRepoManager, telemetry); this._context = this._folderRepoManager.context; this._commentController = this._register(vscode.comments.createCommentController( - `${ReviewCommentController.PREFIX}-${folderRepoManager.activePullRequest?.remote.owner}-${folderRepoManager.activePullRequest?.remote.owner}-${folderRepoManager.activePullRequest!.number}`, + `${ReviewCommentController.PREFIX}-${folderRepoManager.activePullRequest!.remote.owner}-${folderRepoManager.activePullRequest!.remote.repositoryName}-${folderRepoManager.activePullRequest!.number}`, vscode.l10n.t('Pull Request ({0})', folderRepoManager.activePullRequest!.title), )); this._commentController.commentingRangeProvider = this as vscode.CommentingRangeProvider;