changeset 8863:0ce9f0754a46

diffs: drop pointless check for adding context line The length of the match was always 5.
author Mads Kiilerich <mads@kiilerich.com>
date Sun, 21 Feb 2021 23:53:59 +0100
parents ba7c0397c3c1
children 3ab8744d20c9
files kallithea/lib/diffs.py
diffstat 1 files changed, 8 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/diffs.py	Mon Feb 22 12:12:38 2021 +0100
+++ b/kallithea/lib/diffs.py	Sun Feb 21 23:53:59 2021 +0100
@@ -629,19 +629,17 @@
             old_line -= 1
             new_line -= 1
 
-            context = len(gr) == 5
             old_end += old_line
             new_end += new_line
 
-            if context:
-                # skip context only if it's first line
-                if int(gr[0]) > 1:
-                    lines.append({
-                        'old_lineno': '',
-                        'new_lineno': '',
-                        'action':     'context',
-                        'line':       line,
-                    })
+            # include '@@' line if it gives a line number hint or separate chunks - not if the chunk starts at start of file like '@@ -1,7 +1,7 @@'
+            if int(gr[0]) > 1:
+                lines.append({
+                    'old_lineno': '',
+                    'new_lineno': '',
+                    'action':     'context',
+                    'line':       line,
+                })
 
             line = next(diff_lines)