mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-27 00:32:14 +01:00
Merge pull request #972 from makhov/the-new-new-highlighting
fix typo mistake in highlighting
This commit is contained in:
commit
8f1d2d9f24
2 changed files with 17 additions and 16 deletions
|
@ -209,27 +209,28 @@ var Gogs = {};
|
||||||
$list.parents('tr').removeClass('end-selected-line');
|
$list.parents('tr').removeClass('end-selected-line');
|
||||||
$list.parents('tr').find('td').removeClass('selected-line');
|
$list.parents('tr').find('td').removeClass('selected-line');
|
||||||
if ($from) {
|
if ($from) {
|
||||||
var expr = new RegExp(/diff-(\w+)([LR])(\d+)/);
|
var expr = new RegExp(/diff-(\w+)([LR]\d+)/);
|
||||||
var selectMatches = $select.attr('rel').match(expr)
|
var selectMatches = $select.attr('rel').match(expr)
|
||||||
var fromMatches = $from.attr('rel').match(expr)
|
var fromMatches = $from.attr('rel').match(expr)
|
||||||
var a = parseInt(selectMatches[3]);
|
var selectTop = $select.offset().top;
|
||||||
var b = parseInt(fromMatches[3]);
|
var fromTop = $from.offset().top;
|
||||||
var linesIntToStr = {};
|
var hash;
|
||||||
linesIntToStr[a] = selectMatches[3];
|
|
||||||
linesIntToStr[b] = fromMatches[3];
|
|
||||||
|
|
||||||
var c;
|
if (selectMatches[2] != fromMatches[2]) {
|
||||||
if (a != b) {
|
if ((selectTop > fromTop)) {
|
||||||
if (a > b) {
|
$startElem = $from;
|
||||||
c = a;
|
$endElem = $select;
|
||||||
a = b;
|
hash = fromMatches[1]+fromMatches[2] + '-' + selectMatches[2];
|
||||||
b = c;
|
} else {
|
||||||
|
$startElem = $select;
|
||||||
|
$endElem = $from;
|
||||||
|
hash = selectMatches[1]+selectMatches[2] + '-' + fromMatches[2];
|
||||||
}
|
}
|
||||||
$('[rel=diff-'+fromMatches[1] + fromMatches[2] + linesIntToStr[b] + ']').parents('tr').next().addClass('end-selected-line');
|
$endElem.parents('tr').next().addClass('end-selected-line');
|
||||||
var $selectedLines = $('[rel=diff-'+fromMatches[1]+selectMatches[2] + linesIntToStr[a] + ']').parents('tr').nextUntil('.end-selected-line').andSelf();
|
var $selectedLines = $startElem.parents('tr').nextUntil('.end-selected-line').andSelf();
|
||||||
$selectedLines.find('td.lines-num > span').addClass('active')
|
$selectedLines.find('td.lines-num > span').addClass('active')
|
||||||
$selectedLines.find('td').addClass('selected-line');
|
$selectedLines.find('td').addClass('selected-line');
|
||||||
$.changeHash('#diff-'+fromMatches[1]+fromMatches[2] + linesIntToStr[a] + '-' + selectMatches[2] + + linesIntToStr[b]);
|
$.changeHash('#diff-'+hash);
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@
|
||||||
{{range $k, $line := .Lines}}
|
{{range $k, $line := .Lines}}
|
||||||
<tr class="{{DiffLineTypeToStr .Type}}-code nl-{{$k}} ol-{{$k}}">
|
<tr class="{{DiffLineTypeToStr .Type}}-code nl-{{$k}} ol-{{$k}}">
|
||||||
<td class="lines-num lines-num-old">
|
<td class="lines-num lines-num-old">
|
||||||
<span rel="{{if $line.LeftIdx}}diff-L{{Sha1 $file.Name}}{{$line.LeftIdx}}{{end}}">{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}</span>
|
<span rel="{{if $line.LeftIdx}}diff-{{Sha1 $file.Name}}L{{$line.LeftIdx}}{{end}}">{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="lines-num lines-num-new">
|
<td class="lines-num lines-num-new">
|
||||||
<span rel="{{if $line.RightIdx}}diff-{{Sha1 $file.Name}}R{{$line.RightIdx}}{{end}}">{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}</span>
|
<span rel="{{if $line.RightIdx}}diff-{{Sha1 $file.Name}}R{{$line.RightIdx}}{{end}}">{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}</span>
|
||||||
|
|
Loading…
Reference in a new issue