@@ -15,10 +15,7 @@ function selectRange($list, $select, $from) {
1515 // add hashchange to permalink
1616 const $issue = $ ( 'a.ref-in-new-issue' ) ;
1717 const $copyPermalink = $ ( 'a.copy-line-permalink' ) ;
18-
19- if ( $copyPermalink . length === 0 ) {
20- return ;
21- }
18+ const $viewGitBlame = $ ( 'a.view_git_blame' ) ;
2219
2320 const updateIssueHref = function ( anchor ) {
2421 if ( $issue . length === 0 ) {
@@ -29,7 +26,22 @@ function selectRange($list, $select, $from) {
2926 $issue . attr ( 'href' , href ) ;
3027 } ;
3128
29+ const updateViewGitBlameFragment = function ( anchor ) {
30+ if ( $viewGitBlame . length === 0 ) {
31+ return ;
32+ }
33+ let href = $viewGitBlame . attr ( 'href' ) ;
34+ href = `${ href . replace ( / # L \d + $ | # L \d + - L \d + $ / , '' ) } ` ;
35+ if ( anchor . length !== 0 ) {
36+ href = `${ href } #${ anchor } ` ;
37+ }
38+ $viewGitBlame . attr ( 'href' , href ) ;
39+ } ;
40+
3241 const updateCopyPermalinkHref = function ( anchor ) {
42+ if ( $copyPermalink . length === 0 ) {
43+ return ;
44+ }
3345 let link = $copyPermalink . attr ( 'data-clipboard-text' ) ;
3446 link = `${ link . replace ( / # L \d + $ | # L \d + - L \d + $ / , '' ) } #${ anchor } ` ;
3547 $copyPermalink . attr ( 'data-clipboard-text' , link ) ;
@@ -53,6 +65,7 @@ function selectRange($list, $select, $from) {
5365 changeHash ( `#L${ a } -L${ b } ` ) ;
5466
5567 updateIssueHref ( `L${ a } -L${ b } ` ) ;
68+ updateViewGitBlameFragment ( `L${ a } -L${ b } ` ) ;
5669 updateCopyPermalinkHref ( `L${ a } -L${ b } ` ) ;
5770 return ;
5871 }
@@ -61,6 +74,7 @@ function selectRange($list, $select, $from) {
6174 changeHash ( `#${ $select . attr ( 'rel' ) } ` ) ;
6275
6376 updateIssueHref ( $select . attr ( 'rel' ) ) ;
77+ updateViewGitBlameFragment ( $select . attr ( 'rel' ) ) ;
6478 updateCopyPermalinkHref ( $select . attr ( 'rel' ) ) ;
6579}
6680
0 commit comments