From 46598bcad2a5df8af8cd0574e4534ac31169529c Mon Sep 17 00:00:00 2001 From: moculus Date: Wed, 18 Jul 2007 16:15:43 +0000 Subject: [PATCH] fixed at least part of the reverse-search bug --HG-- branch : pmacs2 --- search.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/search.py b/search.py index 73f388f..d3cd102 100644 --- a/search.py +++ b/search.py @@ -52,18 +52,27 @@ def find(r, w, move=False, direction='next', start=None, end=None): offset = 0 if direction == 'next': limit = Point(x - 1 + offset, y) - else: + elif direction == 'previous': limit = Point(x + 1 - offset, y) for stuff in app.highlighted_ranges: (wz, p1, p2, fg, bg) = stuff - if p1.y == c.y and p1.x == c.x: - limit = Point(x + 1 + p2.x - p1.x - offset, y) + #if p1.y == c.y and p1.x == c.x: + if p1 == c: + #raise Exception, "argh you got me: %d (%d + 1 + %d - %d - %d), %d" % (x + 1 + p2.x - p1.x - offset, x, p2.x, p1.x, offset, y) + limit = Point(x + 1 + p2.x - p1.x - 2*offset + 1, y) break indices.reverse() + else: + raise Exception, 'blech' for i in indices: - if ((direction == 'next' and ranges[i][0] > limit) or - (direction != 'next' and ranges[i][1] < limit)): + if direction == 'next' and ranges[i][0] > limit: ranges[i][3] = selected_color + #assert ranges[i][0] > c, "%r > %r" % (ranges[i][0], c) + newc = (ranges[i][0], ranges[i][1]) + break + elif direction == 'previous' and ranges[i][1] < limit: + ranges[i][3] = selected_color + #assert ranges[i][1] < c, "%r < %r" % (ranges[i][1], c) newc = (ranges[i][0], ranges[i][1]) break if ranges and not newc: