fix: open agent file links that carry line-range selectors (#1412)

This commit is contained in:
Clément Fiere
2026-06-17 21:32:40 +02:00
committed by GitHub
parent 67037fd936
commit a71ee2e2c1
14 changed files with 798 additions and 52 deletions
@@ -80,8 +80,12 @@ function stripHashAndQuery(href: string): string {
return href.split(/[?#]/, 1)[0] ?? "";
}
// Strip a trailing source-location / omp read selector so a file link resolves
// to the bare path: ":42", ":42:5", and omp ranges like ":16-20", ":50+150",
// ":5-16,960-973", ":2-4:raw", ":raw", ":conflicts".
function stripSourceLocationSuffix(path: string): string {
return path.replace(/:\d+(?::\d+)?$/, "");
const part = String.raw`\d+(?:[-+]\d+)?(?:,\d+(?:[-+]\d+)?)*|raw|conflicts`;
return path.replace(new RegExp(`:(?:${part})(?::(?:${part}))*$`), "");
}
function decodeHrefPath(href: string): string | null {