Skip to content

Commit 75f3fd7

Browse files
Copilotalexr00
andcommitted
Fix issue link provider to open links in VS Code instead of browser
- Modified IssueLinkProvider.resolveDocumentLink to use webview URIs - Added instanceof check to distinguish between PullRequestModel and IssueModel - Uses toOpenPullRequestWebviewUri for PRs and toOpenIssueWebviewUri for issues - This ensures links like #22 open in VS Code webview instead of external browser Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 3819225 commit 75f3fd7

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/issues/issueLinkProvider.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
*--------------------------------------------------------------------------------------------*/
55
import * as vscode from 'vscode';
66
import { EDITOR, WORD_WRAP } from '../common/settingKeys';
7+
import { toOpenIssueWebviewUri, toOpenPullRequestWebviewUri } from '../common/uri';
78
import { ReposManagerState } from '../github/folderRepositoryManager';
9+
import { PullRequestModel } from '../github/pullRequestModel';
810
import { RepositoriesManager } from '../github/repositoriesManager';
911
import { ISSUE_EXPRESSION, ParsedIssue, parseIssueExpressionOutput } from '../github/utils';
1012
import { StateManager } from './stateManager';
@@ -81,7 +83,22 @@ export class IssueLinkProvider implements vscode.DocumentLinkProvider {
8183
link.mappedLink.parsed,
8284
);
8385
if (issue) {
84-
link.target = await vscode.env.asExternalUri(vscode.Uri.parse(issue.html_url));
86+
// Check if it's a pull request or an issue
87+
if (issue instanceof PullRequestModel) {
88+
// Use pull request webview URI
89+
link.target = await toOpenPullRequestWebviewUri({
90+
owner: issue.remote.owner,
91+
repo: issue.remote.repositoryName,
92+
pullRequestNumber: issue.number,
93+
});
94+
} else {
95+
// Use issue webview URI
96+
link.target = await toOpenIssueWebviewUri({
97+
owner: issue.remote.owner,
98+
repo: issue.remote.repositoryName,
99+
issueNumber: issue.number,
100+
});
101+
}
85102
}
86103
return link;
87104
}

0 commit comments

Comments
 (0)