╭ changed ──────────────╮ │src/ui/Repo/Patches.zig│ ╰───────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │25 pub fn init(allocator: std.mem.Allocator, session: *ui.Session, initial: []const u8, existing: bool) !Source { │ │26 var box = try wgt.Box(ui.Widget).init(allocator, .{ .border_style = null, .direction = .horiz }); │ │27 errdefer box.deinit(allocator); │ │28 - const labels = [_][]const u8{ "from a new fork", "from an existing branch" }; │ │29 - for (labels, 0..) |label, i| { │ │30 - if (session.data.host_kind == .local) { │ │31 - if (i == 0) continue; │ │28 + if (session.data.host_kind != .local) { │ │29 + for ([_][]const u8{ "from a new fork", "from an existing branch" }) |label| { │ │30 + var selector = try wgt.TextBox.init(allocator, label, .{ .border_style = .single, .rounded_corners = true, .wrap_kind = .none }); │ │31 + errdefer selector.deinit(allocator); │ │32 + selector.getFocus().mode = .all; │ │33 + try box.children.put(allocator, selector.getFocus().id, .{ .widget = .{ .text_box = selector }, .rect = null, .min_size = .{ .width = label.len + 2, .height = 3 } }); │ │34 } │ │33 - var selector = try wgt.TextBox.init(allocator, label, .{ .border_style = .single, .rounded_corners = true, .wrap_kind = .none }); │ │34 - errdefer selector.deinit(allocator); │ │35 - selector.getFocus().mode = .all; │ │36 - try box.children.put(allocator, selector.getFocus().id, .{ .widget = .{ .text_box = selector }, .rect = null, .min_size = .{ .width = label.len + 2, .height = 3 } }); │ │35 } │ │36 const input_index = box.children.count(); │ │37 var input_box = try wgt.TextInput.init(allocator, .{ .label = " source branch ", .name = "source_branch", .rounded_corners = true, .visible_width = null, .render_content = session.is_terminal });│ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │39 input_box.getFocus().mode = .all; │ │40 try input_box.setContent(allocator, initial); │ │41 try box.children.put(allocator, input_box.getFocus().id, .{ .widget = .{ .text_input = input_box }, .rect = null, .min_size = .{ .width = 15, .height = 3 } });│ │44 - box.getFocus().child_id = box.children.keys()[if (existing) input_index - 1 else 0]; │ │45 - return .{ .box = box, .session = session, .existing = existing or input_index == 1, .input_index = input_index }; │ │42 + box.getFocus().child_id = box.children.keys()[if (existing and input_index > 0) input_index - 1 else 0]; │ │43 + return .{ .box = box, .session = session, .existing = existing or input_index == 0, .input_index = input_index }; │ │44 } │ │45 │ │46 pub fn field(self: *Source) *wgt.TextInput { │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │74 pub fn input(self: *Source, allocator: std.mem.Allocator, key: xitui.input.Key, root_focus: *xitui.focus.Focus) !void { │ │75 const current = self.box.getFocus().child_id orelse return; │ │76 const index = self.box.children.getIndex(current) orelse return; │ │79 - if (index == self.input_index and key != .arrow_left) return self.field().input(allocator, key, root_focus); │ │77 + if (self.input_index == 0 or (index == self.input_index and key != .arrow_left)) return self.field().input(allocator, key, root_focus);│ │78 switch (key) { │ │79 .arrow_left => if (index > 0) { │ │80 self.existing = index == self.input_index; │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯