diffHighlighter: Correctly match unified diff hunks

Hunks in unified diffs are usually in the form of @@ -a,b +x,y @@, but
sometimes the ,b (i.e. the range) can be ommitted, in which case our
code didn't match the hunk-header at all, resulting in line-numbers
off-by-one in commit-view.

Signed-off-by: Johannes Gilger <heipei@hackvalue.de>
This commit is contained in:
Johannes Gilger
2009-02-21 23:02:14 +01:00
parent 58990fc318
commit 51478449ec
+1 -1
View File
@@ -203,7 +203,7 @@ var highlightDiff = function(diff, element, callbacks) {
header = false;
}
if (m = l.match(/@@ \-([0-9]+),\d+ \+(\d+),\d+ @@/))
if (m = l.match(/@@ \-([0-9]+),?\d* \+(\d+),?\d* @@/))
{
hunk_start_line_1 = parseInt(m[1]) - 1;
hunk_start_line_2 = parseInt(m[2]) - 1;