╭ changed ──────╮ │src/ui/Repo.zig│ ╰───────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────╮ │31 // the full files route this page renders ("owner/name" or "owner/name/files/<dir>"),│ │32 // mirrored into current_page when the files tab is selected. │ │33 route_name: Array, │ │34 +// the content window (?after=N) of that files route; mirrored alongside the name │ │35 +// so the url keeps the query param even when focus isn't in the files view. │ │36 +files_after: usize, │ │37 // the commits route this page renders ("owner/name/commits[/<oid>]"), mirrored │ │38 // when the commits tab is selected. │ │39 commits_route_name: Array, │ ╰─────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────╮ │57 // every repo route's stored string starts with "owner/name"; the files and│ │58 // commits routes additionally encode a ref/oid (files also a directory). │ │59 const name_str: []const u8 = switch (route) { │ │57 - .repo, .repo_settings, .repo_auth => |n| n.slice(), │ │60 + .repo_files => |f| f.name.slice(), │ │61 + .repo_settings, .repo_auth => |n| n.slice(), │ │62 .repo_commits => |c| c.name.slice(), │ │63 .repo_refs => |r| r.name.slice(), │ │64 else => return error.UnexpectedRoute, │ ╰───────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │74 // window only apply to their own tab. │ │75 const commits_ref = if (tag == .repo_commits) ui.RoutablePage.repoCommitsRef(name_str) else ui.RoutablePage.CommitsRef{ .ref_or_oid = null, .value = "" };│ │76 const requested_ref_or_oid: ?ui.RoutablePage.RefOrOid = switch (tag) { │ │73 - .repo => rf.ref_kind, │ │77 + .repo_files => rf.ref_kind, │ │78 .repo_commits => commits_ref.ref_or_oid, │ │79 else => null, │ │80 }; │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────╮ │81 const requested_ref_value: []const u8 = switch (tag) {│ │78 - .repo => rf.ref_value, │ │82 + .repo_files => rf.ref_value, │ │83 .repo_commits => commits_ref.value, │ │84 else => "", │ │85 }; │ ╰──────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────╮ │82 - const files_dir = if (tag == .repo) rf.dir else ""; │ │86 + const files_dir = if (tag == .repo_files) rf.dir else ""; │ │87 + // the line offset the files view's selected file content window starts at. │ │88 + const files_after: usize = switch (route) { │ │89 + .repo_files => |f| f.after, │ │90 + else => 0, │ │91 + }; │ │92 // how many diff hunks the commits view's selected commit shows ("load more").│ │93 const commits_after: usize = switch (route) { │ │94 .repo_commits => |c| c.after, │ ╰──────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │116 // when the route named none) can canonicalize each tab's mirror url to the │ │117 // explicit ref it's viewing rather than leaving it bare. both resolve the │ │118 // same requested ref, so they end up viewing the same one. │ │110 - const files = try Files.init(arena, session, &found.event_id, rf.identity, requested_ref_or_oid, requested_ref_value, files_dir); │ │119 + const files = try Files.init(arena, session, &found.event_id, rf.identity, requested_ref_or_oid, requested_ref_value, files_dir, files_after);│ │120 const commits = try Commits.init(arena, session, &found.event_id, rf.identity, requested_ref_or_oid, requested_ref_value, commits_after); │ │121 │ │122 // each tab mirror carries this page's route for that tab; tabs not targeted │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │124 // mirror carries the selected file (when the route named one) so the url │ │125 // keeps it before focus enters the view. │ │126 const files_path = if (files.selected_file) |f| try Files.childDir(arena.allocator(), files.dir, f) else files.dir; │ │118 - const route_name = (ui.RoutablePage.repoFilesRoute(rf.identity, files.ref_or_oid, files.ref_or_oid_value, files_path) orelse return error.NotFound).repo; │ │127 + // the content window offset only applies to a selected file, so the bare │ │128 + // directory route drops it. │ │129 + const files_route_after = if (files.selected_file != null) files_after else 0; │ │130 + const route_name = (ui.RoutablePage.repoFilesRoute(rf.identity, files.ref_or_oid, files.ref_or_oid_value, files_path, files_route_after) orelse return error.NotFound).repo_files.name;│ │131 const commits_route_name = (ui.RoutablePage.repoCommitsRoute(rf.identity, commits.ref_or_oid, commits.ref_or_oid_value, commits_after) orelse return error.NotFound).repo_commits.name;│ │132 │ │133 return .{ │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────╮ │142 .auth = Auth.init(), │ │143 .quit = Quit.init(), │ │144 .route_name = route_name, │ │145 + .files_after = files_route_after, │ │146 .commits_route_name = commits_route_name, │ │147 .commits_after = commits_after, │ │148 .identity = Array.from(rf.identity) orelse return error.NotFound,│ ╰──────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │249 // alone (nothing to mirror into the url). │ │250 .quit => {}, │ │251 // the files tab (this page's directory route) │ │239 - else => self.session.data.current_page = .{ .repo = self.data.route_name }, │ │252 + else => self.session.data.current_page = .{ .repo_files = .{ .name = self.data.route_name, .after = self.data.files_after } },│ │253 } │ │254 } │ │255 try self.box.build(allocator, constraint, root_focus); │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯