[meld/BufferLines] Fix inconsistent behaviour of BufferLines



commit 42a873584ba0f2a7f6f887fb5f21bb8d241b80c7
Author: Piotr Piastucki <leech miranda gmail com>
Date:   Sat Apr 7 15:55:53 2012 +0200

    Fix inconsistent behaviour of BufferLines

 meld/filediff.py |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index b3bedbf..5dc4df0 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -111,6 +111,7 @@ class BufferLines(object):
         # to artificially add a line if the requested slice is past the end of
         # the buffer, and the last line in the slice ended in a newline.
         if hi >= self.buf.get_line_count() and \
+           lo < self.buf.get_line_count() and \
            (len(lines) == 0 or len(lines[-1]) != len(ends[-1])):
             lines.append(u"")
             ends.append(u"")
@@ -135,7 +136,7 @@ class BufferLines(object):
         return lines
 
     def __getitem__(self, i):
-        if i > len(self):
+        if i >= len(self):
             raise IndexError
         line_start = get_iter_at_line_or_eof(self.buf, i)
         line_end = line_start.copy()



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