diff --git a/extensions/github/src/commands.ts b/extensions/github/src/commands.ts index 7158759c672f5..8a653e523c4ab 100644 --- a/extensions/github/src/commands.ts +++ b/extensions/github/src/commands.ts @@ -15,7 +15,7 @@ function getVscodeDevHost(): string { async function copyVscodeDevLink(gitAPI: GitAPI, useSelection: boolean, context: LinkContext, includeRange = true) { try { - const permalink = getLink(gitAPI, useSelection, getVscodeDevHost(), undefined, context, includeRange); + const permalink = getLink(gitAPI, useSelection, getVscodeDevHost(), 'headlink', context, includeRange); if (permalink) { return vscode.env.clipboard.writeText(permalink); } diff --git a/extensions/github/src/links.ts b/extensions/github/src/links.ts index 5cbdf2e78bccf..e689a28dc90de 100644 --- a/extensions/github/src/links.ts +++ b/extensions/github/src/links.ts @@ -149,7 +149,7 @@ export function getLink(gitAPI: GitAPI, useSelection: boolean, hostPrefix?: stri return; } - const blobSegment = (gitRepo.state.HEAD?.ahead === 0) ? `/blob/${linkType === 'headlink' ? gitRepo.state.HEAD.name : gitRepo.state.HEAD?.commit}` : ''; + const blobSegment = gitRepo.state.HEAD ? (`/blob/${linkType === 'headlink' && gitRepo.state.HEAD.name ? gitRepo.state.HEAD.name : gitRepo.state.HEAD?.commit}`) : ''; const fileSegments = fileAndPosition.type === LinkType.File ? (useSelection ? `${uri.path.substring(gitRepo.rootUri.path.length)}${useRange ? rangeString(fileAndPosition.range) : ''}` : '') : (useSelection ? `${uri.path.substring(gitRepo.rootUri.path.length)}${useRange ? notebookCellRangeString(fileAndPosition.cellIndex, fileAndPosition.range) : ''}` : '');