~ubuntu-branches/ubuntu/lucid/meld/lucid

« back to all changes in this revision

Viewing changes to debian/patches/only-ignore-fully-blank-changes.patch

  • Committer: Bazaar Package Importer
  • Author(s): Ross Burton
  • Date: 2009-06-02 10:00:20 UTC
  • mfrom: (1.2.9 upstream) (2.1.5 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090602100020-jb5wlixbu8xws29a
Tags: 1.3.0-1
* New upstream release (Closes: #528327)
  - Copy/paste behaviour fixes (Closes: #523576)
  - Dotfiles and removals handled in darcs (Closes: #509069)
  - Can handle Mercurial repos (Closes: #428843)
  - Up/Down patch used to skip changes (Closes: #511027)
  - Handle last line when highlighting properly (Closes: #465804)
* Update message and depends for new python-gtksourceview2 package
* Resync makefile.patch
* Remove python-gnome dependency

Show diffs side-by-side

added added

removed removed

Lines of Context:
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.
5
 
 
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 @@
10
 
             self._setup_gcs(area)
11
 
 
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"
17
 
-            outline = True
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):
21
 
-                    outline = False
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 @@
27
 
         if jump_to_first:
28
 
             # curline already has some positive value due to scrollbar size
29
 
             curline = -1
30
 
-        c = None
31
 
+        found = None
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]]):
40
 
                     continue
41
 
                 if c[1] > curline + 1:
42
 
+                    found = c
43
 
                     break
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]]):
50
 
                     continue
51
 
-                if chunk[2] < curline:
52
 
-                    c = chunk
53
 
-                elif c:
54
 
+                if c[2] < curline:
55
 
+                    found = c
56
 
+                elif found:
57
 
                     break
58
 
-        if c:
59
 
+        if found:
60
 
+            c = found
61
 
             if c[2] - c[1]: # no range, use other side
62
 
                 l0,l1 = c[1],c[2]
63
 
                 aidx = 1
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)
67
 
 
68
 
-    def _consume_blank_lines(self, txt):
69
 
-        lo, hi = 0, 0
70
 
-        for l in txt:
71
 
-            if len(l)==0:
72
 
-                lo += 1
73
 
-            else:
74
 
-                break
75
 
-        for l in txt[lo:]:
76
 
-            if len(l)==0:
77
 
-                hi += 1
78
 
-            else:
79
 
-                break
80
 
-        return lo,hi
81
 
+    def _is_ignored(self, c, txt1, txt2):
82
 
+        if not self.prefs.ignore_blank_lines:
83
 
+            return False
84
 
+        for line in txt1[c[1]:c[2]] + txt2[c[3]:c[4]]:
85
 
+            if line.strip():
86
 
+                return False
87
 
+        return True
88
 
 
89
 
         #
90
 
         # linkmap drawing
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)
94
 
 
95
 
-
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]:
102
 
-                    continue
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]):
106
 
+                continue
107
 
 
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
113
 
 
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]:
120
 
-                        continue
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]):
124
 
+                    continue
125
 
                 if c[0] == "insert":
126
 
                     continue
127
 
                 h = func(c)