Skip to content

Commit

Permalink
Splits layout: Special case move_to_edge when there is a single split…
Browse files Browse the repository at this point in the history
… to preserve bias
  • Loading branch information
kovidgoyal committed Jan 17, 2025
1 parent c600451 commit 069868f
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions kitty/layout/splits.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,16 +636,29 @@ def layout_action(self, action_name: str, args: Sequence[str], all_windows: Wind
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
if count == 2: # special case, a single split
pair = self.pairs_root.pair_for_window(wg.id)
if pair is not None:
if which in ('left', 'top'):
if pair.one != wg.id:
pair.one, pair.two = pair.two, pair.one
pair.bias = 1. - pair.bias
else:
if pair.one == wg.id:
pair.one, pair.two = pair.two, pair.one
pair.bias = 1. - pair.bias
return True
else:
new_root.one = self.pairs_root
new_root.two = wg.id
self.pairs_root = new_root
return True
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
elif action_name == 'bias':
args = args or ('50',)
bias = int(args[0])
Expand Down

0 comments on commit 069868f

Please sign in to comment.