mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-25 15:53:36 +01:00
Fix line selection on blame view (#12857)
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 <techknowlogick@gitea.io>
This commit is contained in:
parent
d9085fe176
commit
88823f3e29
2 changed files with 13 additions and 3 deletions
|
@ -2005,14 +2005,24 @@ function initCodeView() {
|
||||||
if ($('.code-view .lines-num').length > 0) {
|
if ($('.code-view .lines-num').length > 0) {
|
||||||
$(document).on('click', '.lines-num span', function (e) {
|
$(document).on('click', '.lines-num span', function (e) {
|
||||||
const $select = $(this);
|
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));
|
selectRange($list, $list.filter(`[rel=${$select.attr('id')}]`), (e.shiftKey ? $list.filter('.active').eq(0) : null));
|
||||||
deSelect();
|
deSelect();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(window).on('hashchange', () => {
|
$(window).on('hashchange', () => {
|
||||||
let m = window.location.hash.match(/^#(L\d+)-(L\d+)$/);
|
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;
|
let $first;
|
||||||
if (m) {
|
if (m) {
|
||||||
$first = $list.filter(`[rel=${m[1]}]`);
|
$first = $list.filter(`[rel=${m[1]}]`);
|
||||||
|
|
|
@ -1122,7 +1122,7 @@ i.icon.centerlock {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.lines-code.active {
|
.active {
|
||||||
background: #fffbdd !important;
|
background: #fffbdd !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue