[meld: 3/4] Disable push to read-only panes for two panes merge.




commit d9bfa3932ce9b0a21ed5d1c12cdde3da3b36be79
Author: Anatoli Babenia <anatoli rainforce org>
Date:   Sun Aug 9 09:08:07 2020 +0300

    Disable push to read-only panes for two panes merge.
    
    There is a difference between "left pane" and "pane to the left".
    For `editable_left` `meld` means the latter. See @kaiw comment
    https://gitlab.gnome.org/GNOME/meld/-/merge_requests/2#note_886994
    
    For example. editable_left `False` for the **left** pane 0, because
    there is no pane to the left of it.
    
        pane 0  editable_left/right: FalseTrue  editable0/1: TrueTrue
        pane 1  editable_left/right: TrueFalse  editable0/1: TrueTrue

 meld/filediff.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index 55c19f45..8efa3b04 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -657,6 +657,8 @@ class FileDiff(Gtk.VBox, MeldDoc):
             # conditions for push are met, *and* there is some content in the
             # target pane.
             editable = self.textview[pane].get_editable()
+            # editable_left is relative to current pane and it is False for the
+            # leftmost frame. The same logic applies to editable_right.
             editable_left = pane > 0 and self.textview[pane - 1].get_editable()
             editable_right = (
                 pane < self.num_panes - 1 and
@@ -693,8 +695,10 @@ class FileDiff(Gtk.VBox, MeldDoc):
 
             # If there is chunk and there are only two panes (#25)
             if self.num_panes == 2:
-                push_right = True
-                push_left = True
+                pane0_editable = self.textview[0].get_editable()
+                pane1_editable = self.textview[1].get_editable()
+                push_left = pane0_editable
+                push_right = pane1_editable
 
         self.set_action_enabled('file-push-left', push_left)
         self.set_action_enabled('file-push-right', push_right)


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