╭ changed ──────────────╮ │src/ui/Repo/Commits.zig│ ╰───────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │437 } │ │438 │ │439 try self.box.build(allocator, constraint, root_focus); │ │440 + │ │441 + // if the diff pane is selected but focus is still elsewhere in this view, │ │442 + // the pane was too narrow to lay out when focus crossed over. it's laid │ │443 + // out now, so focus its hunk. │ │444 + if (self.diffActive() and inner.children.count() > 0) { │ │445 + if (root_focus.grandchild_id) |g| { │ │446 + const in_view = self.box.getFocus().children.contains(g); │ │447 + const in_diff = inner.children.contains(g); │ │448 + if (in_view and !in_diff) │ │449 + try root_focus.setFocus(inner.getFocus().child_id orelse inner.children.keys()[0]);│ │450 + } │ │451 + } │ │452 } │ │453 │ │454 fn refreshDiff(self: *View, allocator: std.mem.Allocator) !void { │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────╮ │621 fn focusDiff(self: *View, root_focus: *Focus) !void { │ │622 const inner = self.diffInner(); │ │623 if (inner.children.count() == 0) return; │ │612 - try root_focus.setFocus(inner.getFocus().child_id orelse inner.children.keys()[0]);│ │624 + const target = inner.getFocus().child_id orelse inner.children.keys()[0]; │ │625 + try root_focus.setFocus(target); │ │626 + if (root_focus.grandchild_id == target) return; │ │627 + // the diff pane wasn't laid out last build (too narrow to show beside │ │628 + // the list), so its hunks aren't in the focus tree yet. select the pane │ │629 + // at the box level, and the hunk will be focused after the next build. │ │630 + self.box.getFocus().child_id = self.diffOuter().getFocus().id; │ │631 } │ │632 │ │633 fn focusList(self: *View, root_focus: *Focus) !void { │ ╰────────────────────────────────────────────────────────────────────────────────────────────────╯