File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -125,19 +125,24 @@ function showLineButton() {
125
125
export function initRepoCodeView ( ) {
126
126
if ( $ ( '.code-view .lines-num' ) . length > 0 ) {
127
127
$ ( document ) . on ( 'click' , '.lines-num span' , function ( e ) {
128
- const $select = $ ( this ) ;
129
- let $list ;
130
- if ( $ ( 'div.blame' ) . length ) {
131
- $list = $ ( '.code-view td.lines-code.blame-code' ) ;
128
+ let linesEls ;
129
+ if ( document . querySelector ( 'div.blame' ) ) {
130
+ linesEls = document . querySelectorAll ( '.code-view td.lines-code.blame-code' ) ;
132
131
} else {
133
- $list = $ ( '.code-view td.lines-code' ) ;
132
+ linesEls = document . querySelectorAll ( '.code-view td.lines-code' ) ;
134
133
}
135
- const $sel = $list . filter ( `[rel=${ $select . attr ( 'id' ) } ]` ) ;
136
- let $from = null ;
134
+
135
+ const selectedEls = Array . from ( linesEls ) . filter ( ( el ) => {
136
+ return el . matches ( `[rel=${ this . getAttribute ( 'id' ) } ]` ) ;
137
+ } ) ;
138
+
139
+ let from ;
137
140
if ( e . shiftKey ) {
138
- $from = $list . closest ( 'tr' ) . filter ( '.active' ) . children ( '.lines-code' ) . eq ( 0 ) ;
141
+ from = Array . from ( linesEls ) . filter ( ( el ) => {
142
+ return el . closest ( 'tr' ) . classList . contains ( 'active' ) ;
143
+ } ) ;
139
144
}
140
- selectRange ( $list , $sel , $ from) ;
145
+ selectRange ( $ ( linesEls ) , $ ( selectedEls ) , from ? $ ( from ) : null ) ;
141
146
142
147
if ( window . getSelection ) {
143
148
window . getSelection ( ) . removeAllRanges ( ) ;
You can’t perform that action at this time.
0 commit comments