╭ changed ───────────╮ │src/ui/Repo/Diff.zig│ ╰────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────╮ │271 const sc = &self.scroll; │ │272 switch (key) { │ │273 // scroll horizontally within the diff │ │274 - .arrow_left => { │ │275 - if (sc.x > 0) { │ │276 - sc.x -= 1; │ │277 - self.scroll.clampToContent(); │ │278 - } │ │274 + .arrow_left => if (!self.moveInRow(root_focus, false) and sc.x > 0) {│ │275 + sc.x -= 1; │ │276 + self.scroll.clampToContent(); │ │277 }, │ │280 - .arrow_right => { │ │278 + .arrow_right => if (!self.moveInRow(root_focus, true)) { │ │279 sc.x += 1; │ │280 self.scroll.clampToContent(); │ │281 }, │ ╰──────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────╮ │293 }, │ │294 else => {}, │ │295 } │ │296 + } │ │297 + │ │298 + // step across the selected row's boxes, false when the row has none that way. │ │299 + pub fn moveInRow(self: *View, root_focus: *Focus, right: bool) bool { │ │300 + const box = self.inner(); │ │301 + const selected = box.getFocus().child_id orelse return false; │ │302 + return switch ((box.children.getPtr(selected) orelse return false).widget) {│ │303 + .box => |*row| ui.widget.moveInRow(row, root_focus, right), │ │304 + else => false, │ │305 + }; │ │306 } │ │307 │ │308 // move one step in `delta` (+ down, - up). in the terminal, `delta` is a │ ╰─────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │312 const box = self.inner(); │ │313 const keys = box.children.keys(); │ │314 if (keys.len == 0) return; │ │307 - const cur: usize = if (root_focus.grandchild_id) |g| (box.children.getIndex(g) orelse 0) else 0;│ │315 + const cur: usize = if (box.getFocus().child_id) |c| (box.children.getIndex(c) orelse 0) else 0; │ │316 const target = @as(isize, @intCast(cur)) + delta; │ │317 const in_range = target >= 0 and target < @as(isize, @intCast(keys.len)); │ │318 │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │348 const box = self.inner(); │ │349 const keys = box.children.keys(); │ │350 if (keys.len == 0) return; │ │343 - const cur: isize = if (root_focus.grandchild_id) |g| @intCast(box.children.getIndex(g) orelse 0) else 0;│ │351 + const cur: isize = if (box.getFocus().child_id) |c| @intCast(box.children.getIndex(c) orelse 0) else 0; │ │352 const target: usize = @intCast(std.math.clamp(cur + delta, 0, @as(isize, @intCast(keys.len - 1)))); │ │353 root_focus.setFocus(keys[target]); │ │354 } │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯