1
# Ubuntu: https://bugs.launchpad.net/ubuntu/+source/meld/+bug/234259
2
# Upstream: http://bugzilla.gnome.org/show_bug.cgi?id=505087
3
# Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=511027.
4
# Description: Avoid skipping some blank lines when moving Up/Down.
6
diff -Nur -x '*.orig' -x '*~' meld-1.2.1-1ubuntu1/filediff.py meld-1.2.1-1ubuntu1.new/filediff.py
7
--- meld-1.2.1-1ubuntu1/filediff.py 2009-05-07 14:41:58.000000000 -0400
8
+++ meld-1.2.1-1ubuntu1.new/filediff.py 2009-05-07 14:54:03.000000000 -0400
9
@@ -1035,13 +1035,10 @@
12
gc = area.meldgc.get_gc
13
- for c in self.linediffer.single_changes(textindex, self._get_texts()):
14
+ texts = self._get_texts()
15
+ for c in self.linediffer.single_changes(textindex, texts):
16
assert c[0] != "equal"
18
- if self.prefs.ignore_blank_lines:
19
- c1,c2 = self._consume_blank_lines( self._get_texts()[textindex][c[1]:c[2]] )
20
- if (c1 or c2) and (c[1]+c1 == c[2]-c2):
22
+ outline = not self._is_ignored(c, texts[textindex], texts[c[5]])
23
s,e = [int(x) for x in ( math.floor(scaleit(c[1])), math.ceil(scaleit(c[2]+(c[1]==c[2]))) ) ]
24
window.draw_rectangle( gc(c[0]), 1, x0, s, x1, e-s)
25
if outline: window.draw_rectangle( gctext, 0, x0, s, x1, e-s)
26
@@ -1095,25 +1092,26 @@
28
# curline already has some positive value due to scrollbar size
32
+ texts = self._get_texts()
33
if direction == gdk.SCROLL_DOWN:
34
- for c in self.linediffer.single_changes(1, self._get_texts()):
35
+ for c in self.linediffer.single_changes(1, texts):
36
assert c[0] != "equal"
37
- c1,c2 = self._consume_blank_lines( self._get_texts()[1][c[1]:c[2]] )
38
- if c[1]+c1 == c[2]-c2:
39
+ if self._is_ignored(c, texts[1], texts[c[5]]):
41
if c[1] > curline + 1:
44
else: #direction == gdk.SCROLL_UP
45
- for chunk in self.linediffer.single_changes(1, self._get_texts()):
46
- c1,c2 = self._consume_blank_lines( self._get_texts()[1][chunk[1]:chunk[2]] )
47
- if chunk[1]+c1 == chunk[2]-c2:
48
+ for c in self.linediffer.single_changes(1, texts):
49
+ if self._is_ignored(c, texts[1], texts[c[5]]):
51
- if chunk[2] < curline:
61
if c[2] - c[1]: # no range, use other side
64
@@ -1139,19 +1137,13 @@
65
area.meldgc = misc.struct(gc_delete=gcd, gc_insert=gcd, gc_replace=gcc, gc_conflict=gcx)
66
area.meldgc.get_gc = lambda p: getattr(area.meldgc, "gc_"+p)
68
- def _consume_blank_lines(self, txt):
81
+ def _is_ignored(self, c, txt1, txt2):
82
+ if not self.prefs.ignore_blank_lines:
84
+ for line in txt1[c[1]:c[2]] + txt2[c[3]:c[4]]:
91
@@ -1195,14 +1187,10 @@
92
return [self._pixel_to_line(idx, pix_start[idx]), self._pixel_to_line(idx, pix_start[idx]+htotal)]
93
visible = [None] + bounds(which) + bounds(which+1)
96
- for c in self.linediffer.pair_changes(which, which+1, self._get_texts()):
97
- if self.prefs.ignore_blank_lines:
98
- c1,c2 = self._consume_blank_lines( self._get_texts()[which ][c[1]:c[2]] )
99
- c3,c4 = self._consume_blank_lines( self._get_texts()[which+1][c[3]:c[4]] )
100
- c = c[0], c[1]+c1,c[2]-c2, c[3]+c3,c[4]-c4
101
- if c[1]==c[2] and c[3]==c[4]:
103
+ texts = self._get_texts()
104
+ for c in self.linediffer.pair_changes(which, which+1, texts):
105
+ if self._is_ignored(c, texts[which], texts[which+1]):
108
assert c[0] != "equal"
109
if c[2] < visible[1] and c[4] < visible[3]: # find first visible chunk
110
@@ -1302,13 +1290,10 @@
111
adj = self.scrolledwindow[src].get_vadjustment()
112
func = lambda c: self._line_to_pixel(src, c[1]) - adj.value
114
- for c in self.linediffer.pair_changes(src, dst, self._get_texts()):
115
- if self.prefs.ignore_blank_lines:
116
- c1,c2 = self._consume_blank_lines( self._get_texts()[src][c[1]:c[2]] )
117
- c3,c4 = self._consume_blank_lines( self._get_texts()[dst][c[3]:c[4]] )
118
- c = c[0], c[1]+c1,c[2]-c2, c[3]+c3,c[4]-c4
119
- if c[1]==c[2] and c[3]==c[4]:
121
+ texts = self._get_texts()
122
+ for c in self.linediffer.pair_changes(src, dst, texts):
123
+ if self._is_ignored(c, texts[src], texts[dst]):