Lines 12–26 at 318 (were 12–18 at 203)
1212// in another (a file split in two), which the trail follows into the file it 15−import type { Atom, AtomId, Graph, LineId, ReadView, SeqLine } from "../../src/engine/index.ts";
23+} from "../../src/engine/index.ts"; 1725/** One change in a line's past, newest first. */ 1826export interface TrailStep { Lines 202–208 at 318 (were 194–199 at 203)
196204 samePush: (a: Atom, b: Atom) => boolean = (a, b) => a.id === b.id, 205+ pushmates?: (atom: Atom) => Iterable<AtomId> | undefined, 197206): { steps: TrailStep[]; more: boolean } { 198207 const files = new Map<string, { seq: readonly SeqLine[]; index: Map<LineId, number> }>(); 199208 const sequenceOf = (path: string) => { Lines 227–233 at 318 (were 218–224 at 203)
218227 const { seq, index } = sequenceOf(path); 219228 const at = index.get(id); 220229 if (at === undefined) continue; 221− const hunk = hunkOf(graph, seq, at, graph.atom(seq[at]!.atom));
230+ const hunk = hunkOf(seq, at, graph.atom(seq[at]!.atom)); 223232 hunk.before.map((i) => seq[i]!.text), 224233 hunk.after.map((i) => seq[i]!.text), Lines 243–257 at 318 (were 234–240 at 203)
234243 let formatting = pair?.formatting ?? false; 235244 let searched = false; 236245 if (replaced === undefined) { 237− const moved = movedFrom(graph, view, atom, seq[at]!.text, new Set(hunk.before.map((i) => seq[i]!.id)), samePush);
246+ const moved = movedFrom( 251+ new Set(hunk.before.map((i) => seq[i]!.id)), 238255 if (moved) [replaced, formatting, searched] = [moved, true, true]; 240257 const maybeMoved = searched || (replaced !== undefined && graph.lineFile(replaced) !== graph.lineFile(id)); Lines 294–317 at 318 (were 277–290 at 203)
278295 skip: ReadonlySet<LineId>, 279296 samePush: (a: Atom, b: Atom) => boolean, 297+ pushmates?: (atom: Atom) => Iterable<AtomId> | undefined, 280298): LineId | undefined { 281299 const want = normalize([text]); 282300 if (want.length < 12) return undefined; 283301 const all = graph.atoms(); 284302 const exact: LineId[] = []; 285303 const same: LineId[] = []; 286− for (let s = Math.max(0, atom.seq - NEAR); s <= Math.min(all.length - 1, atom.seq + NEAR); s++) {
287− const other = all[s]!;
304+ // Only atoms pushed with this one can count (samePush), so where the caller can list them, those are the candidates 305+ // (abso Capacity): reading every atom within NEAR of it was 10,000 atom reads a step on abso. Otherwise, every atom 306+ // near by, as before. 307+ const mates = pushmates?.(atom); 308+ const near = (s: number) => s >= atom.seq - NEAR && s <= atom.seq + NEAR; 309+ const candidates: Iterable<Atom> = mates 310+ ? [...mates].filter((id) => near(seqOf(id))).map((id) => graph.atom(id)) 312+ for (let s = Math.max(0, atom.seq - NEAR); s <= Math.min(all.length - 1, atom.seq + NEAR); s++) yield all[s]!; 314+ for (const other of candidates) { 288315 if (other.author !== atom.author || !view.set.has(other.id) || !samePush(other, atom)) continue; 289316 for (const d of other.deletes) { 290317 if (skip.has(d)) continue; Lines 331–337 at 318 (were 304–311 at 203)
304331 * Lines nobody could see when it was made (written later, or already 305332 * deleted) are passed over; a line it left alone ends the hunk. 307−function hunkOf(graph: Graph, seq: readonly SeqLine[], at: number, atom: Atom): { before: number[]; after: number[] } {
308− const seqOf = (id: AtomId) => graph.atom(id).seq;
334+function hunkOf(seq: readonly SeqLine[], at: number, atom: Atom): { before: number[]; after: number[] } { 309335 const role = (s: SeqLine): "wrote" | "deleted" | "unseen" | "kept" => { 310336 if (s.atom === atom.id) return "wrote"; 311337 if (seqOf(s.atom) > atom.seq) return "unseen";