11import type { ConfigurationChangeEvent } from 'vscode' ;
22import { Disposable } from 'vscode' ;
3+ import type { OpenIssueActionContext } from '../api/gitlens' ;
4+ import { OpenIssueOnRemoteCommand } from '../commands/openIssueOnRemote' ;
35import { GlyphChars } from '../constants' ;
46import type { IntegrationIds } from '../constants.integrations' ;
7+ import type { Source } from '../constants.telemetry' ;
58import type { Container } from '../container' ;
69import type { GitRemote } from '../git/models/remote' ;
710import type { RemoteProvider , RemoteProviderId } from '../git/remotes/remoteProvider' ;
@@ -279,6 +282,7 @@ export class AutolinksProvider implements Disposable {
279282 enrichedAutolinks ?: Map < string , MaybeEnrichedAutolink > ,
280283 prs ?: Set < string > ,
281284 footnotes ?: Map < number , string > ,
285+ source ?: Source ,
282286 ) : string {
283287 const includeFootnotesInText = outputFormat === 'plaintext' && footnotes == null ;
284288 if ( includeFootnotesInText ) {
@@ -291,15 +295,31 @@ export class AutolinksProvider implements Disposable {
291295 for ( const [ , [ , link ] ] of enrichedAutolinks ) {
292296 if ( this . ensureAutolinkCached ( link ) ) {
293297 if ( link . tokenize != null ) {
294- text = link . tokenize ( text , outputFormat , tokenMapping , enrichedAutolinks , prs , footnotes ) ;
298+ text = link . tokenize (
299+ text ,
300+ outputFormat ,
301+ tokenMapping ,
302+ enrichedAutolinks ,
303+ prs ,
304+ footnotes ,
305+ source ,
306+ ) ;
295307 }
296308 }
297309 }
298310 } else {
299311 for ( const ref of this . _references ) {
300312 if ( this . ensureAutolinkCached ( ref ) ) {
301313 if ( ref . tokenize != null ) {
302- text = ref . tokenize ( text , outputFormat , tokenMapping , enrichedAutolinks , prs , footnotes ) ;
314+ text = ref . tokenize (
315+ text ,
316+ outputFormat ,
317+ tokenMapping ,
318+ enrichedAutolinks ,
319+ prs ,
320+ footnotes ,
321+ source ,
322+ ) ;
303323 }
304324 }
305325 }
@@ -323,6 +343,7 @@ export class AutolinksProvider implements Disposable {
323343 enrichedAutolinks ,
324344 prs ,
325345 footnotes ,
346+ source ,
326347 ) ;
327348 }
328349 }
@@ -361,6 +382,7 @@ export class AutolinksProvider implements Disposable {
361382 enrichedAutolinks ?: Map < string , MaybeEnrichedAutolink > ,
362383 prs ?: Set < string > ,
363384 footnotes ?: Map < number , string > ,
385+ source ?: Source ,
364386 ) => {
365387 let footnoteIndex : number ;
366388
@@ -370,7 +392,15 @@ export class AutolinksProvider implements Disposable {
370392 return text . replace (
371393 ref . messageMarkdownRegex ,
372394 ( _ : string , prefix : string , linkText : string , num : string ) => {
373- const url = encodeUrl ( ref . url . replace ( numRegex , num ) ) ;
395+ const rawUrl = encodeUrl ( ref . url . replace ( numRegex , num ) ) ;
396+ const footnoteSource = source && { ...source , detail : 'footnote' } ;
397+ const urlCommandContext : {
398+ provider : undefined | OpenIssueActionContext [ 'provider' ] ;
399+ issue : { url : string } ;
400+ } = {
401+ provider : undefined ,
402+ issue : { url : rawUrl } ,
403+ } ;
374404
375405 let title = '' ;
376406 if ( ref . title ) {
@@ -380,6 +410,10 @@ export class AutolinksProvider implements Disposable {
380410 if ( issueResult ?. value != null ) {
381411 if ( issueResult . paused ) {
382412 if ( footnotes != null && ! prs ?. has ( num ) ) {
413+ const url = OpenIssueOnRemoteCommand . createMarkdownCommandLink ( {
414+ ...urlCommandContext ,
415+ source : footnoteSource ,
416+ } ) ;
383417 const name =
384418 ref . description ?. replace ( numRegex , num ) ??
385419 `Custom Autolink ${ ref . prefix } ${ num } ` ;
@@ -396,6 +430,16 @@ export class AutolinksProvider implements Disposable {
396430 const issueTitle = escapeMarkdown ( issue . title . trim ( ) ) ;
397431 const issueTitleQuoteEscaped = issueTitle . replace ( / " / g, '\\"' ) ;
398432
433+ urlCommandContext . provider = issue . provider && {
434+ id : issue . provider . id ,
435+ name : issue . provider . name ,
436+ domain : issue . provider . domain ,
437+ } ;
438+ const url = OpenIssueOnRemoteCommand . createMarkdownCommandLink ( {
439+ ...urlCommandContext ,
440+ source : footnoteSource ,
441+ } ) ;
442+
399443 if ( footnotes != null && ! prs ?. has ( num ) ) {
400444 footnoteIndex = footnotes . size + 1 ;
401445 footnotes . set (
@@ -417,6 +461,10 @@ export class AutolinksProvider implements Disposable {
417461 ) } `;
418462 }
419463 } else if ( footnotes != null && ! prs ?. has ( num ) ) {
464+ const url = OpenIssueOnRemoteCommand . createMarkdownCommandLink ( {
465+ ...urlCommandContext ,
466+ source : footnoteSource ,
467+ } ) ;
420468 const name =
421469 ref . description ?. replace ( numRegex , num ) ??
422470 `Custom Autolink ${ ref . prefix } ${ num } ` ;
@@ -429,6 +477,10 @@ export class AutolinksProvider implements Disposable {
429477 title += '"' ;
430478 }
431479
480+ const url = OpenIssueOnRemoteCommand . createMarkdownCommandLink ( {
481+ ...urlCommandContext ,
482+ source : source ,
483+ } ) ;
432484 const token = `\x00${ tokenMapping . size } \x00` ;
433485 tokenMapping . set ( token , `[${ linkText } ](${ url } ${ title } )` ) ;
434486 return `${ prefix } ${ token } ` ;
0 commit comments