Skip to content

Commit

Permalink
Fix line selection on blame view (#12857)
Browse files Browse the repository at this point in the history
Blame and regular code view have diverge slightly so line highlighting wasn't working properly anymore. Make work again in lieu of a larger refactor of blame HTML to move it outside of source and into templates to match code view.

Fixes #12836

Co-authored-by: techknowlogick <[email protected]>
  • Loading branch information
mrsdizzie and techknowlogick committed Sep 15, 2020
1 parent d9085fe commit 88823f3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions web_src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2005,14 +2005,24 @@ function initCodeView() {
if ($('.code-view .lines-num').length > 0) {
$(document).on('click', '.lines-num span', function (e) {
const $select = $(this);
const $list = $('.code-view td.lines-code');
let $list;
if ($('div.blame').length) {
$list = $('.code-view td.lines-code li');
} else {
$list = $('.code-view td.lines-code');
}
selectRange($list, $list.filter(`[rel=${$select.attr('id')}]`), (e.shiftKey ? $list.filter('.active').eq(0) : null));
deSelect();
});

$(window).on('hashchange', () => {
let m = window.location.hash.match(/^#(L\d+)-(L\d+)$/);
const $list = $('.code-view td.lines-code');
let $list;
if ($('div.blame').length) {
$list = $('.code-view td.lines-code li');
} else {
$list = $('.code-view td.lines-code');
}
let $first;
if (m) {
$first = $list.filter(`[rel=${m[1]}]`);
Expand Down
2 changes: 1 addition & 1 deletion web_src/less/_base.less
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@ i.icon.centerlock {
width: 100%;
}

.lines-code.active {
.active {
background: #fffbdd !important;
}

Expand Down

0 comments on commit 88823f3

Please sign in to comment.