Skip to content

Commit 726a9aa

Browse files
committed
Merge branch 'altkeys' into 'master'
Unconditional Alt+Right and Alt+Left for two-pane merges (#25) See merge request GNOME/meld!2
2 parents 17422e8 + d9bfa39 commit 726a9aa

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

meld/filediff.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,8 @@ def on_current_diff_changed(self, *args):
657657
# conditions for push are met, *and* there is some content in the
658658
# target pane.
659659
editable = self.textview[pane].get_editable()
660+
# editable_left is relative to current pane and it is False for the
661+
# leftmost frame. The same logic applies to editable_right.
660662
editable_left = pane > 0 and self.textview[pane - 1].get_editable()
661663
editable_right = (
662664
pane < self.num_panes - 1 and
@@ -691,6 +693,13 @@ def on_current_diff_changed(self, *args):
691693
copy_right = (
692694
editable_right and right_mid_exists and right_exists)
693695

696+
# If there is chunk and there are only two panes (#25)
697+
if self.num_panes == 2:
698+
pane0_editable = self.textview[0].get_editable()
699+
pane1_editable = self.textview[1].get_editable()
700+
push_left = pane0_editable
701+
push_right = pane1_editable
702+
694703
self.set_action_enabled('file-push-left', push_left)
695704
self.set_action_enabled('file-push-right', push_right)
696705
self.set_action_enabled('file-pull-left', pull_left)
@@ -815,9 +824,10 @@ def action_next_diff(self, *args):
815824

816825
def get_action_chunk(self, src, dst):
817826
valid_panes = list(range(0, self.num_panes))
818-
if (src not in valid_panes or dst not in valid_panes or
819-
self.cursor.chunk is None):
827+
if src not in valid_panes or dst not in valid_panes:
820828
raise ValueError("Action was taken on invalid panes")
829+
if self.cursor.chunk is None:
830+
raise ValueError("Action was taken without chunk")
821831

822832
chunk = self.linediffer.get_chunk(self.cursor.chunk, src, dst)
823833
if chunk is None:
@@ -853,11 +863,17 @@ def on_chunk_action_activated(
853863
self.copy_chunk(from_pane, to_pane, chunk, copy_up=False)
854864

855865
def action_push_change_left(self, *args):
856-
src, dst = self.get_action_panes(PANE_LEFT)
866+
if self.num_panes == 2:
867+
src, dst = 1, 0
868+
else:
869+
src, dst = self.get_action_panes(PANE_LEFT)
857870
self.replace_chunk(src, dst, self.get_action_chunk(src, dst))
858871

859872
def action_push_change_right(self, *args):
860-
src, dst = self.get_action_panes(PANE_RIGHT)
873+
if self.num_panes == 2:
874+
src, dst = 0, 1
875+
else:
876+
src, dst = self.get_action_panes(PANE_RIGHT)
861877
self.replace_chunk(src, dst, self.get_action_chunk(src, dst))
862878

863879
def action_pull_change_left(self, *args):

0 commit comments

Comments
 (0)