Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1154)

Unified Diff: third_party/WebKit/Tools/Scripts/webkitpy/common/html_diff.py

Issue 2699083002: html_diff: Show context lines at the beginning/end of a file correctly. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/common/html_diff_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Tools/Scripts/webkitpy/common/html_diff.py
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/common/html_diff.py b/third_party/WebKit/Tools/Scripts/webkitpy/common/html_diff.py
index d645d72d89e9de7c051d5c6d8108a75a7808a606..44ab18b942666820c1ddb9ac850bbbf7a8d2e164 100644
--- a/third_party/WebKit/Tools/Scripts/webkitpy/common/html_diff.py
+++ b/third_party/WebKit/Tools/Scripts/webkitpy/common/html_diff.py
@@ -50,6 +50,7 @@ class HtmlDiffGenerator(object):
self.a_line_no = 0
self.b_line_no = 0
self.a_lines_len = len(a_lines)
+ self.b_lines_len = len(b_lines)
matcher = difflib.SequenceMatcher(None, a_lines, b_lines)
output = []
for tag, a_start, a_end, b_start, b_end in matcher.get_opcodes():
@@ -73,7 +74,7 @@ class HtmlDiffGenerator(object):
output += self._format_equal_line(line)
else:
# Do not show context lines at the beginning of the file.
- if self.a_line_no == 0:
+ if self.a_line_no == 0 and self.b_line_no == 0:
self.a_line_no += 3
self.b_line_no += 3
else:
@@ -83,7 +84,7 @@ class HtmlDiffGenerator(object):
self.b_line_no += len(common_chunk) - 6
output += '<tr><td colspan=3>\n\n</tr>'
# Do not show context lines at the end of the file.
- if self.a_line_no + 3 != self.a_lines_len:
+ if self.a_line_no + 3 != self.a_lines_len or self.b_line_no + 3 != self.b_lines_len:
for line in common_chunk[len(common_chunk) - 3:len(common_chunk)]:
output += self._format_equal_line(line)
return output
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/common/html_diff_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698