@@ -177,33 +177,37 @@ export default defineComponent({
177177 }
178178 },
179179 /**
180- * When a commit is clicked with shift this enables the range
181- * selection. Second click (with shift) defines the end of the
182- * range. This opens the diff of this range
180+ * When a commit is clicked while holding Shift, it enables range selection.
181+ * - The start of the commit range is always the previous commit of the first clicked commit.
182+ * - If the first commit in the list is clicked, the mergeBase will be used as the start of the range instead.
183+ * - The second Shift-click defines the end of the range.
184+ * - Once both are selected, the diff view for the selected commit range will open.
183185 */
184186 commitClickedShift(commit : Commit ) {
185187 this .hoverActivated = ! this .hoverActivated ;
186188 commit .selected = true ;
187189 // Second click -> determine our range and open links accordingly
188190 if (! this .hoverActivated ) {
191+ // since at least one commit is selected, we can determine the range
189192 // find all selected commits and generate a link
190193 const firstSelected = this .commits .findIndex ((x ) => x .selected );
191- let start: string ;
194+ const lastSelected = this .commits .findLastIndex ((x ) => x .selected );
195+ let beforeCommitID: string ;
192196 if (firstSelected === 0 ) {
193- start = this .mergeBase ;
197+ beforeCommitID = this .mergeBase ;
194198 } else {
195- start = this .commits [firstSelected - 1 ].id ;
199+ beforeCommitID = this .commits [firstSelected - 1 ].id ;
196200 }
201+ const afterCommitID = this .commits [lastSelected ].id ;
197202
198- const end = this .commits .findLast ((x ) => x .selected ).id ;
199- if (start === end ) {
203+ if (firstSelected === lastSelected ) {
200204 // if the start and end are the same, we show this single commit
201- window .location .assign (` ${this .issueLink }/commits/${start }${this .queryParams } ` );
202- } else if (start === this .mergeBase && end === this .commits .at (- 1 ).id ) {
205+ window .location .assign (` ${this .issueLink }/commits/${afterCommitID }${this .queryParams } ` );
206+ } else if (beforeCommitID === this .mergeBase && afterCommitID === this .commits .at (- 1 ).id ) {
203207 // if the first commit is selected and the last commit is selected, we show all commits
204208 window .location .assign (` ${this .issueLink }/files${this .queryParams } ` );
205209 } else {
206- window .location .assign (` ${this .issueLink }/files/${start }..${end }${this .queryParams } ` );
210+ window .location .assign (` ${this .issueLink }/files/${beforeCommitID }..${afterCommitID }${this .queryParams } ` );
207211 }
208212 }
209213 },
0 commit comments