diff --git a/docs/changelog.rst b/docs/changelog.rst index c0558ba19..fbd8bfd56 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -85,6 +85,10 @@ Detailed list of changes - hints kitten: Fix common single letter extension files not being detected (:iss:`4491`) +- For the vertical and horizontal layouts have the windows arranged on a ring + rather than a plane. This means the first and last window are considered + neighbors (:iss:`4494`) + 0.24.1 [2022-01-06] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/layout/vertical.py b/kitty/layout/vertical.py index afd06ced4..afd8094ca 100644 --- a/kitty/layout/vertical.py +++ b/kitty/layout/vertical.py @@ -123,8 +123,12 @@ class Vertical(Layout): assert wg is not None groups = tuple(all_windows.iter_all_layoutable_groups()) idx = groups.index(wg) - before = [] if wg is groups[0] else [groups[idx-1].id] - after = [] if wg is groups[-1] else [groups[idx+1].id] + lg = len(groups) + if lg > 1: + before = [groups[(idx - 1 + lg) % lg].id] + after = [groups[(idx + 1) % lg].id] + else: + before, after = [], [] if self.main_is_horizontal: return {'left': before, 'right': after, 'top': [], 'bottom': []} return {'top': before, 'bottom': after, 'left': [], 'right': []}