[meld: 4/7] filediff: Factor out common direction handling in next-diff
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld: 4/7] filediff: Factor out common direction handling in next-diff
- Date: Sun, 3 Nov 2019 00:56:56 +0000 (UTC)
commit e4b664d23a3e1018f0e4931affef48c5dfb7583f
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sun Nov 3 08:19:32 2019 +1000
filediff: Factor out common direction handling in next-diff
meld/filediff.py | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index 6006d754..75f1c7d2 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -604,8 +604,8 @@ class FileDiff(Gtk.VBox, MeldDoc):
def next_diff(self, direction, centered=False, use_viewport=False):
# use_viewport: seek next and previous diffes based on where
# the user is currently scrolling at.
- target = (self.cursor.next if direction == Gdk.ScrollDirection.DOWN
- else self.cursor.prev)
+ scroll_down = direction == Gdk.ScrollDirection.DOWN
+ target = self.cursor.next if scroll_down else self.cursor.prev
if use_viewport:
@@ -623,12 +623,8 @@ class FileDiff(Gtk.VBox, MeldDoc):
halfline = self.textview[pane].get_line_at_y(
halfscreen).target_iter.get_line()
- (current, prev, next) = self.linediffer.locate_chunk(1, halfline)
-
- if direction == Gdk.ScrollDirection.DOWN:
- target = next
- else:
- target = prev
+ (current, prev, next_) = self.linediffer.locate_chunk(1, halfline)
+ target = next_ if scroll_down else prev
self.go_to_chunk(target, centered=centered)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]