[meld] filediff: Do not add ranges that are empty



commit 095b83319c733fb1002aaa7147a767e8d719cf1e
Author: Jason Gauci <jgauci apple com>
Date:   Mon Feb 1 00:45:58 2016 -0800

    filediff: Do not add ranges that are empty

 meld/filediff.py |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index 733543a..507a48a 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -765,14 +765,16 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
                 for match in filt.filter.finditer(txt):
                     # If there are no groups in the match, use the whole match
                     if not filt.filter.groups:
-                        filter_ranges.append(match.span())
+                        span = match.span()
+                        if span[0] != span[1]:
+                            filter_ranges.append(span)
                         continue
 
                     # If there are groups in the regex, include all groups that
                     # participated in the match
                     for i in range(filt.filter.groups):
                         span = match.span(i + 1)
-                        if span != (-1, -1):
+                        if span != (-1, -1) and span[0] != span[1]:
                             filter_ranges.append(span)
 
             filter_ranges = misc.merge_intervals(filter_ranges)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]