╭──────────╮ │← previous│ ╰──────────╯ ╭ changed ─────────────╮ │src/ui/Repo/Events.zig│ ╰──────────────────────╯ ╭─────────────────────────────────────────────────────────────────────╮ │507 return box.children.getIndex(id) == 0 and scroll.y == 0;│ │508 } │ │509 │ │510 - pub fn getSelectedIndex(self: *View) ?usize { │ │511 - return if (self.headerActive()) 0 else 1; │ │510 + pub fn atTop(self: *View) bool { │ │511 + return self.headerActive(); │ │512 } │ │513 │ │514 pub fn clearGrid(self: *View) void { │ ╰─────────────────────────────────────────────────────────────────────╯ ╭ changed ────────────╮ │src/ui/Repo/Files.zig│ ╰─────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────╮ │748 } │ │749 │ │750 // only the clone-url row sits directly below the repository header. │ │751 - pub fn getSelectedIndex(self: *View) ?usize { │ │752 - if (self.headerActive()) return 0; │ │753 - return if (self.header().hasCloneUrl() or !self.contentAtTop()) 1 else 0; │ │751 + pub fn atTop(self: *View) bool { │ │752 + return self.headerActive() or (!self.header().hasCloneUrl() and self.contentAtTop());│ │753 } │ │754 │ │755 pub fn focusCloneUrl(self: *View, root_focus: *Focus) bool { │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭ changed ───────────╮ │src/ui/Repo/Refs.zig│ ╰────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────╮ │337 return self.box.getFocus(); │ │338 } │ │339 │ │340 - // the selected row's offset within the active column (0 = first row), so the│ │341 - // parent knows when up should escape to the header. │ │342 - pub fn getSelectedIndex(self: View) ?usize { │ │343 - var copy = self; │ │344 - const col = copy.activeColumn() orelse return null; │ │345 - const cur_id = col.getFocus().child_id orelse return null; │ │346 - return col.children.getIndex(cur_id); │ │340 + pub fn atTop(self: *View) bool { │ │341 + const col = self.activeColumn() orelse return false; │ │342 + const cur_id = col.getFocus().child_id orelse return false; │ │343 + return col.children.getIndex(cur_id) == 0; │ │344 } │ │345 }; │ │346 │ ╰──────────────────────────────────────────────────────────────────────────────────────╯ ╭ changed ──────────╮ │src/ui/Settings.zig│ ╰───────────────────╯ ╭─────────────────────────────────────────────────────╮ │121 return self.focus; │ │122 } │ │123 │ │124 - pub fn getSelectedIndex(self: View) ?usize {│ │124 + pub fn atTop(self: View) bool { │ │125 _ = self; │ │126 - return 0; │ │126 + return true; │ │127 } │ │128 }; │ │129 │ ╰─────────────────────────────────────────────────────╯ ╭ changed ──────╮ │src/ui/User.zig│ ╰───────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────╮ │296 }, │ │297 .stack => { │ │298 if (child.stack.getSelected()) |selected_widget| { │ │299 - const at_top = switch (selected_widget.*) { │ │300 - .flow_box_scroll => |*v| v.getSelectedIndex() == 0,│ │301 - .home_settings => |*v| v.getSelectedIndex() == 0, │ │302 - .home_auth => |*v| v.getSelectedIndex() == 0, │ │303 - .quit => |*v| v.getSelectedIndex() == 0, │ │304 - else => false, │ │305 - }; │ │306 - if (at_top) { │ │299 + if (selected_widget.atTop(root_focus)) { │ │300 index = header_index; │ │301 } else { │ │302 try child.input(allocator, key, root_focus); │ ╰────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭ changed ────────╮ │src/ui/widget.zig│ ╰─────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ 98 inline else => |*case| return case.getFocus(), │ │ 99 } │ │100 } │ │101 + │ │102 + // whether moving up should return to the page header │ │103 + pub fn atTop(self: *Widget, root_focus: *Focus) bool { │ │104 + return switch (self.*) { │ │105 + inline .home_users, .home_repos, .flow_box_scroll, .home_settings, .home_auth, .quit, .repo_files, .repo_commits, .repo_refs, .repo_issues, .repo_patches, .repo_discussions, .repo_events => |*view| view.atTop(),│ │106 + .repo_patch_detail => |*view| view.atTop(root_focus), │ │107 + else => false, │ │108 + }; │ │109 + } │ │110 }; │ │111 │ │112 pub const back_button_width = 3; │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────╮ │419 return self.scroll.getFocus(); │ │420 } │ │421 │ │413 - pub fn getSelectedIndex(self: Scroll) ?usize { │ │422 + pub fn atTop(self: Scroll) bool { │ │423 const in = self.scroll.child.flow_box; │ │415 - const child_id = in.focus.child_id orelse return null; │ │416 - return in.indexOfFocusId(child_id); │ │424 + const child_id = in.focus.child_id orelse return false;│ │425 + return in.indexOfFocusId(child_id) == 0; │ │426 } │ │427 │ │428 fn inner(self: *Scroll) *FlowBox { │ ╰────────────────────────────────────────────────────────────────────────╯ ╭ changed ───────────────╮ │src/ui/widget/thread.zig│ ╰────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────╮ │2749 // for the parent's "scroll up at the top jumps to the header" check: at the│ │2750 // top only while the header tabs hold focus, so up from the split │ │2751 // crosses into the tabs first. │ │2752 - pub fn getSelectedIndex(self: *This) ?usize { │ │2753 - return if (self.headerActive()) 0 else 1; │ │2752 + pub fn atTop(self: *This) bool { │ │2753 + return self.headerActive(); │ │2754 } │ │2755 }; │ │2756 } │ ╰──────────────────────────────────────────────────────────────────────────────────────────╯