@@ -8412,7 +8412,7 @@ function drawerFor(
84128412 from,
84138413 count,
84148414 );
8415- const admitted = held.roundsWindowed
8415+ const admitted = held.historyWindowed
84168416 ? content.map((one) => one.described)
84178417 : windowed(content, context, entering, view.focused, asking, reveals);
84188418 const readings =
@@ -8826,7 +8826,7 @@ function inspectionContent(
88268826
88278827/** What one drawer reading holds, before any window decides what is shown. */
88288828interface DrawerContent {
8829- readonly roundsWindowed ?: true;
8829+ readonly historyWindowed ?: true;
88308830 readonly title: string;
88318831 /**
88328832 * What the title is, which is not the same for every drawer.
@@ -8894,7 +8894,7 @@ function drawerContent(
88948894 preview?: readonly ReplFittedLine[] | undefined,
88958895 notices?: ReplPreparedNotices,
88968896 details?: readonly ReplFittedLine[],
8897- roundWindow ?: Pick<ReplWindow, "from" | "count">,
8897+ historyWindow ?: Pick<ReplWindow, "from" | "count">,
88988898): DrawerContent | undefined {
88998899 const open = view.selection.drawers[view.selection.drawers.length - 1];
89008900 if (open === undefined && presentedCatalog(view)) {
@@ -8921,7 +8921,7 @@ function drawerContent(
89218921 // its own text would let what it is in front of show through from where that
89228922 // text stopped, because a renderer writes what changed and nothing else.
89238923 const content: DrawerRow[] = [];
8924- let roundsWindowed : true | undefined;
8924+ let historyWindowed : true | undefined;
89258925 let title: string;
89268926 /** What the title reads as. Ordinary unless this drawer is a question. */
89278927 let titleStyle: ReplRowStyle = styleOf("drawer-title");
@@ -9011,12 +9011,29 @@ function drawerContent(
90119011 // the selected prefix, without reading their payloads.
90129012 const rounds = historyRounds(view);
90139013 if (rounds === undefined) {
9014- for (const one of [...numbered(view.navigation)].reverse()) {
9014+ const points = numbered(view.navigation);
9015+ historyWindowed = historyWindow !== undefined && points.length > 0 ? true : undefined;
9016+ const from = historyWindow?.from ?? 0;
9017+ const end = Math.min(points.length, from + (historyWindow?.count ?? points.length));
9018+ for (let index = from; index < end; index++) {
9019+ const position = points.length - 1 - index;
9020+ const one = points[position];
9021+ const newer = index === from ? points[position + 1] : undefined;
9022+ const older = index === end - 1 ? points[position - 1] : undefined;
9023+ const up = newer === undefined ? undefined : `drawer:marker:${newer.point.marker}`;
9024+ const down = older === undefined ? undefined : `drawer:marker:${older.point.marker}`;
90159025 content.push({
90169026 described: row(
90179027 `drawer:marker:${one.point.marker}`,
90189028 padControl(pointLabel(one.point, one.ordinal, one.entry), width),
9019- { select: "marker", marker: one.point.marker },
9029+ {
9030+ select: "marker",
9031+ marker: one.point.marker,
9032+ reveal: {
9033+ ...(up === undefined ? {} : { ArrowUp: up, "Alt+ArrowUp": up }),
9034+ ...(down === undefined ? {} : { ArrowDown: down, "Alt+ArrowDown": down }),
9035+ },
9036+ },
90209037 styleOf("history", {
90219038 selected: view.state.route.at === one.point.marker,
90229039 inspected: true,
@@ -9027,10 +9044,10 @@ function drawerContent(
90279044 }
90289045 } else {
90299046 const entries = new Map(view.model.entries.map((entry) => [entry.order, entry]));
9030- roundsWindowed = roundWindow === undefined ? undefined : true;
9031- const from = roundWindow ?.from ?? 0;
9047+ historyWindowed = historyWindow === undefined ? undefined : true;
9048+ const from = historyWindow ?.from ?? 0;
90329049 const visible =
9033- roundWindow === undefined ? rounds : rounds.slice(from, from + roundWindow .count);
9050+ historyWindow === undefined ? rounds : rounds.slice(from, from + historyWindow .count);
90349051 const numberWidth = String(rounds[0].input.entry).length;
90359052 // Keyboard neighbours still come from the whole list.
90369053 for (const [offset, round] of visible.entries()) {
@@ -9131,7 +9148,7 @@ function drawerContent(
91319148 content.push(...built.content);
91329149 }
91339150
9134- if (content.length === 0 && roundsWindowed !== true) {
9151+ if (content.length === 0 && historyWindowed !== true) {
91359152 content.push({ described: drawerLine("drawer:empty", " ", width, styleOf("metadata")) });
91369153 }
91379154 return {
@@ -9140,7 +9157,7 @@ function drawerContent(
91409157 dismissing,
91419158 entering,
91429159 content,
9143- ...(roundsWindowed ? { roundsWindowed } : {}),
9160+ ...(historyWindowed ? { historyWindowed } : {}),
91449161 };
91459162}
91469163
@@ -12612,16 +12629,22 @@ function offsetFor(
1261212629 return held;
1261312630 }
1261412631 const requested = view.state.restore;
12615- const rounds = window === DRAWER_WINDOW ? historyRounds(view) : undefined;
12616- if (rounds !== undefined) {
12632+ if (window === DRAWER_WINDOW && view.selection.drawers.at(-1)?.kind === "history") {
1261712633 if (requested?.kind === "reveal" && capacity > 0) {
12618- const at = rounds.findIndex(
12619- (round) =>
12620- requested.key === `drawer:marker:${round.input.point.marker}` ||
12621- (round.output !== undefined &&
12622- requested.key === `drawer:marker:${round.output.point.marker}`),
12623- );
12624- if (at >= 0) {
12634+ const rounds = historyRounds(view);
12635+ const points = view.navigation.checkpoints;
12636+ const at =
12637+ rounds === undefined
12638+ ? points.length -
12639+ 1 -
12640+ points.findIndex((point) => requested.key === `drawer:marker:${point.marker}`)
12641+ : rounds.findIndex(
12642+ (round) =>
12643+ requested.key === `drawer:marker:${round.input.point.marker}` ||
12644+ (round.output !== undefined &&
12645+ requested.key === `drawer:marker:${round.output.point.marker}`),
12646+ );
12647+ if (at >= 0 && at < total) {
1262512648 return Math.min(Math.max(held, at - capacity + 1), at);
1262612649 }
1262712650 }
@@ -12769,12 +12792,10 @@ function totalOf(
1276912792 }
1277012793 // The same prepared rows the drawing pass consumes, so what this window
1277112794 // admits and what it draws cannot disagree about how tall a notice is.
12772- const rounds = historyRounds(view);
12773- return (
12774- rounds?.length ??
12775- drawerContent(view, widths?.drawer ?? 0, preview, notices, details)?.content.length ??
12776- 0
12777- );
12795+ if (window === DRAWER_WINDOW && view.selection.drawers.at(-1)?.kind === "history") {
12796+ return historyRounds(view)?.length ?? Math.max(1, view.navigation.checkpoints.length);
12797+ }
12798+ return drawerContent(view, widths?.drawer ?? 0, preview, notices, details)?.content.length ?? 0;
1277812799}
1277912800
1278012801/**
0 commit comments