[meld] dirdiff: Maintain pane order in marked comparisons



commit 8f37141419005d103b1ec1042c5dcfd085eb03c2
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sat Mar 12 09:13:57 2022 +1000

    dirdiff: Maintain pane order in marked comparisons
    
    If the user marks file X in the left pane and compares file Y in the
    right, the launched comparison should be the same as if they mark file
    Y in the right and compare with file X in the left; in both cases, the
    comparison should be X -> Y.

 meld/dirdiff.py | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index f99b7167..2e024431 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -1478,10 +1478,17 @@ class DirDiff(Gtk.VBox, tree.TreeviewCommon, MeldDoc):
         if selected is None:
             return
 
-        row_paths = [
-            self.model.value_paths(self.marked['mark'])[self.marked['pane']],
-            self.model.value_paths(selected)[pane]
-        ]
+        mark, mark_pane = self.marked['mark'], self.marked['pane']
+        marked_path = self.model.value_paths(mark)[mark_pane]
+        selected_path = self.model.value_paths(selected)[pane]
+
+        # Maintain the pane ordering in the new comparison, regardless
+        # of which pane is the marked one.
+        if pane < mark_pane:
+            row_paths = [selected_path, marked_path]
+        else:
+            row_paths = [marked_path, selected_path]
+
         gfiles = [Gio.File.new_for_path(p)
                   for p in row_paths if os.path.exists(p)]
         self.create_diff_signal.emit(gfiles, {})


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