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

Fixes #4494
This commit is contained in:
Kovid Goyal 2022-01-11 08:08:11 +05:30
parent 7023c7a8ae
commit 4c8ef26141
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 10 additions and 2 deletions

View File

@ -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]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -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': []}