From d5e45cf8d3b16b1c80f79b5c95252f3abd0c4368 Mon Sep 17 00:00:00 2001 From: Siriwat Uamganmsup Date: Mon, 2 Mar 2026 13:53:59 +0700 Subject: [PATCH] Splits layout: Fix variable shadowing in layout_pair causing corrupted pane positions The for loops iterating over edge_border() results in layout_pair() used top, bottom, left, right as loop variable names, which shadowed the function's local variables tracking current layout position. This caused sibling panes to be positioned at incorrect offsets when splitting a pane that was itself a nested Pair (e.g. splitting the left pane horizontally would cause the right pane to shift down half the screen). Rename loop variables to etop, ebottom, eleft, eright to avoid shadowing. --- kitty/layout/splits.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/kitty/layout/splits.py b/kitty/layout/splits.py index 6571bf960..bd2ff376b 100644 --- a/kitty/layout/splits.py +++ b/kitty/layout/splits.py @@ -272,8 +272,8 @@ class Pair: if isinstance(self.one, Pair): self.one.layout_pair(left, top, w1, height, id_window_map, layout_object) if bw: - for top, bottom, window_id in self.one.edge_border(RIGHT_EDGE, id_window_map): - one.append(BorderLine(Edges(bleft, top, bleft + bw, bottom), window_id=window_id)) + for etop, ebottom, window_id in self.one.edge_border(RIGHT_EDGE, id_window_map): + one.append(BorderLine(Edges(bleft, etop, bleft + bw, ebottom), window_id=window_id)) else: wg = id_window_map[self.one] yl = next(layout_object.ylayout(iter((wg,)), start=top, size=height, border_mult=border_mult)) @@ -287,8 +287,8 @@ class Pair: if isinstance(self.two, Pair): self.two.layout_pair(left, top, w2, height, id_window_map, layout_object) if bw: - for top, bottom, window_id in self.two.edge_border(LEFT_EDGE, id_window_map): - two.append(BorderLine(Edges(left - bw, top, left, bottom), window_id=window_id)) + for etop, ebottom, window_id in self.two.edge_border(LEFT_EDGE, id_window_map): + two.append(BorderLine(Edges(left - bw, etop, left, ebottom), window_id=window_id)) else: wg = id_window_map[self.two] if bw: @@ -310,8 +310,8 @@ class Pair: if isinstance(self.one, Pair): self.one.layout_pair(left, top, width, h1, id_window_map, layout_object) if bw: - for left, right, window_id in self.one.edge_border(BOTTOM_EDGE, id_window_map): - one.append(BorderLine(Edges(left, btop, right, btop + bw), window_id=window_id)) + for eleft, eright, window_id in self.one.edge_border(BOTTOM_EDGE, id_window_map): + one.append(BorderLine(Edges(eleft, btop, eright, btop + bw), window_id=window_id)) else: wg = id_window_map[self.one] xl = next(layout_object.xlayout(iter((wg,)), start=left, size=width, border_mult=border_mult)) @@ -325,8 +325,8 @@ class Pair: if isinstance(self.two, Pair): self.two.layout_pair(left, top, width, h2, id_window_map, layout_object) if bw: - for left, right, window_id in self.two.edge_border(TOP_EDGE, id_window_map): - two.append(BorderLine(Edges(left, top - bw, right, top), window_id=window_id)) + for eleft, eright, window_id in self.two.edge_border(TOP_EDGE, id_window_map): + two.append(BorderLine(Edges(eleft, top - bw, eright, top), window_id=window_id)) else: wg = id_window_map[self.two] if bw: