╭ changed ──────────────╮ │src/ui/Repo/Comment.zig│ ╰───────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │142 const metadata_index: usize = 0; │ │143 const body_index: usize = 1; │ │144 const gap_index: usize = 2; │ │145 - const metadata_first_link_index: usize = 1; │ │145 │ │146 pub fn init(allocator: std.mem.Allocator, session: *ui.Session, identity: []const u8, thread_kind: evt.EventKind, entry: CommentWithId) !Item {│ │147 var box = try wgt.Box(ui.Widget).init(allocator, .{ .border_style = null, .direction = .vert }); │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │150 { │ │151 var bar = try wgt.Box(ui.Widget).init(allocator, .{ .border_style = null, .direction = .horiz }); │ │152 errdefer bar.deinit(allocator); │ │154 - │ │155 - var spacer = try ui.widget.Spacer.init(allocator); │ │156 - errdefer spacer.deinit(allocator); │ │157 - try bar.children.put(allocator, spacer.getFocus().id, .{ .widget = .{ .spacer = spacer }, .rect = null, .min_size = null }); │ │153 │ │154 + // the author sits on the left and the buttons on the right │ │155 var author = try ui.authorBox(allocator, session.page_arena, entry.author); │ │156 errdefer author.deinit(allocator); │ │157 try bar.children.put(allocator, author.getFocus().id, .{ .widget = .{ .text_box = author }, .rect = null, .min_size = null, .flex = .shrink });│ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │158 + │ │159 + var spacer = try ui.widget.Spacer.init(allocator); │ │160 + errdefer spacer.deinit(allocator); │ │161 + try bar.children.put(allocator, spacer.getFocus().id, .{ .widget = .{ .spacer = spacer }, .rect = null, .min_size = null }); │ │162 │ │163 var reply = try linkBox(allocator, session, "new reply", commentNewRoute(thread_kind, identity, &entry.comment.event.thread_id, &entry.id) orelse return error.RouteTooLong);│ │164 errdefer reply.deinit(allocator); │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │198 try bar.children.put(allocator, remove.getFocus().id, .{ .widget = .{ .text_box = remove }, .rect = null, .min_size = .{ .width = 3, .height = null } });│ │199 } │ │200 │ │201 - bar.getFocus().child_id = bar.children.keys()[metadata_first_link_index]; │ │201 + bar.getFocus().child_id = bar.children.keys()[0]; │ │202 try box.children.put(allocator, bar.getFocus().id, .{ .widget = .{ .box = bar }, .rect = null, .min_size = null }); │ │203 } │ │204 │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │231 │ │232 pub fn focusMetadata(self: *Item, root_focus: *Focus) void { │ │233 const bar = self.metadata(); │ │234 - root_focus.setFocus(bar.getFocus().child_id orelse bar.children.keys()[metadata_first_link_index]);│ │234 + root_focus.setFocus(bar.getFocus().child_id orelse bar.children.keys()[0]); │ │235 } │ │236 │ │237 pub fn focusBody(self: *Item, root_focus: *Focus) void { │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │242 if (self.bodyFocused()) return false; │ │243 const bar = self.metadata(); │ │244 const selected = bar.getFocus().child_id orelse return false; │ │245 - const selected_index = bar.children.getIndex(selected) orelse return false; │ │246 - const target = if (right) selected_index + 1 else selected_index -| 1; │ │247 - if (target < metadata_first_link_index or target >= bar.children.count()) return false; │ │245 + var target = bar.children.getIndex(selected) orelse return false; │ │246 + // step past the spacer between the author and the buttons │ │247 + while (true) { │ │248 + if (right) target += 1 else target = std.math.sub(usize, target, 1) catch return false;│ │249 + if (target >= bar.children.count()) return false; │ │250 + if (bar.children.values()[target].widget != .spacer) break; │ │251 + } │ │252 root_focus.setFocus(bar.children.keys()[target]); │ │253 return true; │ │254 } │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────╯