Skip to content

Link to local file for permalinks in webview#8583

Open
Daniel-Aaron-Bloom wants to merge 10 commits intomicrosoft:mainfrom
Daniel-Aaron-Bloom:main
Open

Link to local file for permalinks in webview#8583
Daniel-Aaron-Bloom wants to merge 10 commits intomicrosoft:mainfrom
Daniel-Aaron-Bloom:main

Conversation

@Daniel-Aaron-Bloom
Copy link

This pull request adds the functionality to link to a file within the project in a comment on the PR/issue overview pages. This feature creates parity with #5558, so links appear and function identically in both locations. It also enables users to quickly jump around using a list of referenced file locations in the PR description or a comment.

Fixes #8571

This PR also adds a few await this._waitForReady; in _replyMessage and _throwError, which I think are the correct behavior, and also without them this extension sometimes fails to respond.

@Daniel-Aaron-Bloom
Copy link
Author

@microsoft-github-policy-service agree

@Daniel-Aaron-Bloom
Copy link
Author

Yup. Much cleaner and more efficient. I've also added diff link support to open the diff view.

Copy link
Member

@alexr00 alexr00 left a comment

Choose a reason for hiding this comment

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

This is heading in a good direction! A few more comments:


// Process blob permalinks (exclude already processed links)
const blobPattern = new RegExp(
`<a\\s+(?![^>]*data-permalink-processed)([^>]*?href="https?:\/\/${escapedAuthority}\/${escapedRepoOwner}\/${escapedRepoName}\/blob\/[0-9a-f]{40}\/(?<filePath>[^"#]+)#L(?<startLine>\\d+)(?:-L(?<endLine>\\d+))?"[^>]*?)>(?<linkText>[^<]*?)<\/a>`,
Copy link
Member

Choose a reason for hiding this comment

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

Should a link like this work (I know it's a private repo, but the structure of the link): https://github.com/alexr00/playground/blob/f86be02708e48ed4648b224771995c7573213946/readme.md?#L6

I'm not seeing it get replaced for a PR in that repo.

Copy link
Author

@Daniel-Aaron-Bloom Daniel-Aaron-Bloom Mar 18, 2026

Choose a reason for hiding this comment

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

It should work, I'm using it in private repos right now (and it's being very helpful). It only doesn't replace the permalinks if the file doesn't exist locally (so you have to check out a PR branch before opening the view) and diff links if the files isn't present in the diff.

These two should show up in this repo, although at the time I made this comment the latter did not because of the different repoOwner (it has since been updated and now both appear to work):

https://github.com/microsoft/vscode-pull-request-github/pull/8583/changes#diff-0660e0b0f883e874d471ed55dbd1bc1a9e009f9422952d55ac7979b8daa23141R77

https://github.com/Daniel-Aaron-Bloom/vscode-pull-request-github/blob/854b78ed243e91c2e431dca323c33a06c2fe343e/common/views.ts#L14

Copy link
Author

Choose a reason for hiding this comment

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

Screenshot 2026-03-18 at 8 58 48 AM

All 4 are clickable and work properly for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Local-ized Links in PR and Issue Overviews

2 participants