mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
diffHighlighter.js: Record the line index as attribute.
This commit is contained in:
@@ -98,7 +98,7 @@ var highlightDiff = function(diff, element, callbacks) {
|
||||
startname = "";
|
||||
endname = "";
|
||||
}
|
||||
for (var lineno = 0; lineno < lines.length; lineno++) {
|
||||
for (var lineno = 0, lindex = 0; lineno < lines.length; lineno++) {
|
||||
var l = lines[lineno];
|
||||
|
||||
var firstChar = l.charAt(0);
|
||||
@@ -186,6 +186,7 @@ var highlightDiff = function(diff, element, callbacks) {
|
||||
continue;
|
||||
}
|
||||
|
||||
sindex = "index=" + lindex.toString() + " ";
|
||||
if (firstChar == "+") {
|
||||
// Highlight trailing whitespace
|
||||
if (m = l.match(/\s+$/))
|
||||
@@ -193,11 +194,11 @@ var highlightDiff = function(diff, element, callbacks) {
|
||||
|
||||
line1 += "\n";
|
||||
line2 += ++hunk_start_line_2 + "\n";
|
||||
diffContent += "<div class='addline'>" + l + "</div>";
|
||||
diffContent += "<div " + sindex + "class='addline'>" + l + "</div>";
|
||||
} else if (firstChar == "-") {
|
||||
line1 += ++hunk_start_line_1 + "\n";
|
||||
line2 += "\n";
|
||||
diffContent += "<div class='delline'>" + l + "</div>";
|
||||
diffContent += "<div " + sindex + "class='delline'>" + l + "</div>";
|
||||
} else if (firstChar == "@") {
|
||||
if (header) {
|
||||
header = false;
|
||||
@@ -210,12 +211,13 @@ var highlightDiff = function(diff, element, callbacks) {
|
||||
}
|
||||
line1 += "...\n";
|
||||
line2 += "...\n";
|
||||
diffContent += "<div class='hunkheader'>" + l + "</div>";
|
||||
diffContent += "<div " + sindex + "class='hunkheader'>" + l + "</div>";
|
||||
} else if (firstChar == " ") {
|
||||
line1 += ++hunk_start_line_1 + "\n";
|
||||
line2 += ++hunk_start_line_2 + "\n";
|
||||
diffContent += "<div class='noopline'>" + l + "</div>";
|
||||
diffContent += "<div " + sindex + "class='noopline'>" + l + "</div>";
|
||||
}
|
||||
lindex++;
|
||||
}
|
||||
|
||||
finishContent();
|
||||
@@ -227,3 +229,4 @@ var highlightDiff = function(diff, element, callbacks) {
|
||||
if (false)
|
||||
Controller.log_("Total time:" + (new Date().getTime() - start));
|
||||
}
|
||||
diffContent += "<div " + sindex + "class='addline'>" + l + "</div>";
|
||||
|
||||
Reference in New Issue
Block a user