You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix permalinks on the same line merging in review comments - #9240
When a review comment has two code permalinks to the repository on the same line, the comment widget in the editor shows only one code snippet and drops the rest of the line. For example, Compare https://github.com/owner/repo/blob/<sha>/src/a.ts#L1 and https://github.com/owner/repo/blob/<sha>/src/b.ts#L2-L3 is shown as a single snippet of src/b.ts: the src/a.ts link and the word "and" are gone, and the src/b.ts link points to the whole text from the first URL to the second one. Why: GHPRComment.replacePermalink matches the owner with (.+) and the file path with (.*). Both are greedy, so one match runs from the first https://github.com/ to the last #L on the line.
This PR limits the owner to one path segment ([^/\s]+) and the file path to the text before the # ([^#\s]+), so each permalink is matched and expanded on its own.
How to test
Command
Result
npm run compile:test, then the repo's extension test runner (out/src/test/index.js through @vscode/test-electronrunTests, with a local VS Code Insiders 1.148.0 instead of the download in out/src/test/runTests.js)
1430 passing; the new test "permalink replacement expands each permalink when there are several on one line" fails without the change
When a review comment has two code permalinks to the repository on the same line, the comment widget in the editor shows only one code snippet and drops the rest of the line. For example, `Compare https://github.com/owner/repo/blob/<sha>/src/a.ts#L1 and https://github.com/owner/repo/blob/<sha>/src/b.ts#L2-L3` is shown as a single snippet of `src/b.ts`: the `src/a.ts` link and the word "and" are gone, and the `src/b.ts` link points to the whole text from the first URL to the second one. Why: `GHPRComment.replacePermalink` matches the owner with `(.+)` and the file path with `(.*)`. Both are greedy, so one match runs from the first `https://github.com/` to the last `#L` on the line.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Compare the full replaced body, so the test also fails when the text around the permalinks is lost or when two permalinks end up in one expansion.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The test’s mock extension URI can cause an unhandled emoji-cache loading rejection and cache the failure, affecting later tests; it should use the real extension URI before constructing GHPRComment.
Set mock extension URI before constructing GHPRComment
src/test/github/prComment.test.ts:123
If this test runs before the emoji cache is initialized, constructing GHPRComment tries to load resources/emojis.json relative to the mock context's test-directory URI, causing an unhandled rejection. The failed load also stays cached and can affect later tests. Set the mock's extensionUri to the real extension URI before constructing the comment, following src/test/github/issueOverview.test.ts:72.
`GHPRComment` loads the emojis relative to the context's extension URI, and the mock context points to the test folder, which has no `resources/emojis.json`. Run on its own, the test left an unhandled rejection and a cached failed load for later tests. Set the real extension URI, as the issue overview tests do.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
One or more custom setup steps configured for this repository failed during this Copilot code review run:
Install dependencies
Setup steps run before each review. If the review above is missing context, or no review was posted at all, the failing step above may be the cause. See the workflow run for failure details, fix your setup steps configuration, and re-request a review.
Note
You can configure setup steps for Copilot code review separately from Copilot cloud agent with a copilot-code-review.yml file. Read the docs for details.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a review comment has two code permalinks to the repository on the same line, the comment widget in the editor shows only one code snippet and drops the rest of the line. For example,
Compare https://github.com/owner/repo/blob/<sha>/src/a.ts#L1 and https://github.com/owner/repo/blob/<sha>/src/b.ts#L2-L3is shown as a single snippet ofsrc/b.ts: thesrc/a.tslink and the word "and" are gone, and thesrc/b.tslink points to the whole text from the first URL to the second one. Why:GHPRComment.replacePermalinkmatches the owner with(.+)and the file path with(.*). Both are greedy, so one match runs from the firsthttps://github.com/to the last#Lon the line.This PR limits the owner to one path segment (
[^/\s]+) and the file path to the text before the#([^#\s]+), so each permalink is matched and expanded on its own.How to test
npm run compile:test, then the repo's extension test runner (out/src/test/index.jsthrough@vscode/test-electronrunTests, with a local VS Code Insiders 1.148.0 instead of the download inout/src/test/runTests.js)npx eslint src/github/prComment.ts,npx tsc --noEmit -p tsconfig.json,node ./build/hygiene.js src/github/prComment.ts src/test/github/prComment.test.ts,npm run compile