Skip to content

Commit bce27c7

Browse files
committed
Always show entries in the file list, even when there is no diff
Fixes renamed files with no changes having no link anchor point
1 parent df68065 commit bce27c7

File tree

1 file changed

+18
-30
lines changed

1 file changed

+18
-30
lines changed

Resources/html/lib/diffHighlighter.js

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -84,39 +84,27 @@ var highlightDiff = function(diff, element, callbacks) {
8484
else if (startname != endname)
8585
title = startname + " renamed to " + endname;
8686

87-
if (binary && endname == "/dev/null") { // in cases of a deleted binary file, there is no diff/file to display
88-
line1 = "";
89-
line2 = "";
90-
diffContent = "";
91-
file_index++;
92-
startname = "";
93-
endname = "";
94-
return; // so printing the filename in the file-list is enough
95-
}
96-
97-
if (diffContent != "" || binary) {
98-
finalContent += '<div class="file" id="file_index_' + (file_index - 1) + '">' +
99-
'<div id="title_' + title + '" class="expanded fileHeader"><a href="javascript:toggleDiff(\'' + title + '\');">' + title + '</a></div>';
100-
}
101-
102-
if (!binary && (diffContent != "")) {
103-
finalContent += '<div id="content_' + title + '" class="diffContent">' +
104-
'<div class="lineno">' + line1 + "</div>" +
105-
'<div class="lineno">' + line2 + "</div>" +
106-
'<div class="lines">' + postProcessDiffContents(diffContent).replace(/\t/g, " ") + "</div>" +
107-
'</div>';
108-
}
109-
else {
110-
if (binary) {
111-
if (callbacks["binaryFile"])
112-
finalContent += callbacks["binaryFile"](binaryname);
113-
else
114-
finalContent += '<div id="content_' + title + '">Binary file differs</div>';
87+
// Show file list header
88+
finalContent += '<div class="file" id="file_index_' + (file_index - 1) + '">';
89+
finalContent += '<div id="title_' + title + '" class="expanded fileHeader"><a href="javascript:toggleDiff(\'' + title + '\');">' + title + '</a></div>';
90+
91+
if (binary) {
92+
// diffContent is assumed to be empty for binary files
93+
if (callbacks["binaryFile"]) {
94+
finalContent += callbacks["binaryFile"](binaryname);
95+
} else {
96+
finalContent += '<div id="content_' + title + '">Binary file differs</div>';
11597
}
98+
} else if (diffContent != "") {
99+
finalContent += '<div id="content_' + title + '" class="diffContent">' +
100+
'<div class="lineno">' + line1 + '</div>' +
101+
'<div class="lineno">' + line2 + '</div>' +
102+
'<div class="lines">' + postProcessDiffContents(diffContent).replace(/\t/g, " ") + '</div>' +
103+
'</div>';
116104
}
117105

118-
if (diffContent != "" || binary)
119-
finalContent += '</div>' + linkToTop;
106+
// Close div.file
107+
finalContent += '</div>' + linkToTop;
120108

121109
line1 = "";
122110
line2 = "";

0 commit comments

Comments
 (0)