@@ -15,10 +15,7 @@ function selectRange($list, $select, $from) {
15
15
// add hashchange to permalink
16
16
const $issue = $ ( 'a.ref-in-new-issue' ) ;
17
17
const $copyPermalink = $ ( 'a.copy-line-permalink' ) ;
18
-
19
- if ( $copyPermalink . length === 0 ) {
20
- return ;
21
- }
18
+ const $viewGitBlame = $ ( 'a.view_git_blame' ) ;
22
19
23
20
const updateIssueHref = function ( anchor ) {
24
21
if ( $issue . length === 0 ) {
@@ -29,7 +26,22 @@ function selectRange($list, $select, $from) {
29
26
$issue . attr ( 'href' , href ) ;
30
27
} ;
31
28
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
+
32
41
const updateCopyPermalinkHref = function ( anchor ) {
42
+ if ( $copyPermalink . length === 0 ) {
43
+ return ;
44
+ }
33
45
let link = $copyPermalink . attr ( 'data-clipboard-text' ) ;
34
46
link = `${ link . replace ( / # L \d + $ | # L \d + - L \d + $ / , '' ) } #${ anchor } ` ;
35
47
$copyPermalink . attr ( 'data-clipboard-text' , link ) ;
@@ -53,6 +65,7 @@ function selectRange($list, $select, $from) {
53
65
changeHash ( `#L${ a } -L${ b } ` ) ;
54
66
55
67
updateIssueHref ( `L${ a } -L${ b } ` ) ;
68
+ updateViewGitBlameFragment ( `L${ a } -L${ b } ` ) ;
56
69
updateCopyPermalinkHref ( `L${ a } -L${ b } ` ) ;
57
70
return ;
58
71
}
@@ -61,6 +74,7 @@ function selectRange($list, $select, $from) {
61
74
changeHash ( `#${ $select . attr ( 'rel' ) } ` ) ;
62
75
63
76
updateIssueHref ( $select . attr ( 'rel' ) ) ;
77
+ updateViewGitBlameFragment ( $select . attr ( 'rel' ) ) ;
64
78
updateCopyPermalinkHref ( $select . attr ( 'rel' ) ) ;
65
79
}
66
80
0 commit comments