Splits layout: Fix the move_to_screen_edge action breaking when only a single window is present

Fixes #7621
This commit is contained in:
Kovid Goyal 2024-07-12 12:13:31 +05:30
parent 870607aa38
commit e0a7d25dda
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 23 additions and 15 deletions

View file

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

View file

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