From e0a7d25ddad2b94d4c330579bdbd45e5b5ca59a5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 12 Jul 2024 12:13:31 +0530 Subject: [PATCH] Splits layout: Fix the move_to_screen_edge action breaking when only a single window is present Fixes #7621 --- docs/changelog.rst | 2 ++ kitty/layout/splits.py | 36 +++++++++++++++++++++--------------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 7d41cf1e8..f1ae2dbd5 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -90,6 +90,8 @@ Detailed list of changes - Wayland: Fix an issue with mouse selections not being stopped when there are multiple OS windows (:iss:`7381`) +- Splits layout: Fix the ``move_to_screen_edge`` action breaking when only a single window is present (:iss:`7621`) + 0.35.2 [2024-06-22] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/layout/splits.py b/kitty/layout/splits.py index 8ae86c8e2..67a687d60 100644 --- a/kitty/layout/splits.py +++ b/kitty/layout/splits.py @@ -601,21 +601,27 @@ class Splits(Layout): pair.one, pair.two = pair.two, pair.one return True elif action_name == 'move_to_screen_edge': - args = args or ('left',) - which = args[0] - horizontal = which in ('left', 'right') - wg = all_windows.active_group - if wg is not None: - self.remove_windows(wg.id) - new_root = Pair(horizontal) - if which in ('left', 'top'): - new_root.balanced_add(wg.id) - new_root.two = self.pairs_root - else: - new_root.one = self.pairs_root - new_root.two = wg.id - self.pairs_root = new_root - return True + count = 0 + for wid in self.pairs_root.all_window_ids(): + count += 1 + if count > 1: + break + if count > 1: + args = args or ('left',) + which = args[0] + horizontal = which in ('left', 'right') + wg = all_windows.active_group + if wg is not None: + self.remove_windows(wg.id) + new_root = Pair(horizontal) + if which in ('left', 'top'): + new_root.balanced_add(wg.id) + new_root.two = self.pairs_root + else: + new_root.one = self.pairs_root + new_root.two = wg.id + self.pairs_root = new_root + return True return None