From 33afffba5be4b55fd14e2a0381bb864646322137 Mon Sep 17 00:00:00 2001 From: "Pierre N." Date: Fri, 27 Nov 2026 16:34:56 +0700 Subject: [PATCH 1/7] test(e2e): the last page of the long document is edited once Find has selected what it found Find scrolls to the match, and selects it a few frames later, once the scroll has come to rest. The test went on as soon as the paragraph was in view: on a busy machine the selection then came after the test's own caret, and the "!" replaced the word, or went by the caret of before and took the view to page 1. The test timed out on its last page (2 of the last 13 runs on CI). It now waits for the selection. With animation frames made 20 to 250 ms late: 8 of 15 runs failed before, 0 of 24 now. Co-Authored-By: Claude Fable 5.2 --- e2e/plain.spec.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/e2e/plain.spec.ts b/e2e/plain.spec.ts index c8e05ff..f2a908d 100644 --- a/e2e/plain.spec.ts +++ b/e2e/plain.spec.ts @@ -63,6 +63,10 @@ test('a document beyond the browser scroll-height limit reaches, finds and edits }) throw new Error(`${e}\n${JSON.stringify(state)}`) }) + // Find selects what it found once the scroll has come to rest, a few frames after the paragraph is in view. On a + // busy machine that came after the caret was put behind the word, and the "!" replaced the word (or went by the + // caret of before): the selection is awaited + await v.page.waitForFunction(() => getSelection()?.toString() === 'END_MARKER') await input.press('Escape') await v.selectText('END_MARKER', 'end') await v.page.keyboard.type('!') From f99b93349d986e9accb2b417d57972b34064c440 Mon Sep 17 00:00:00 2001 From: "Pierre N." Date: Fri, 27 Nov 2026 16:34:56 +0700 Subject: [PATCH 2/7] fix(docx): a tracked change next to one of mine goes on with it, whatever the clock says Every tracked edit is stamped with its own time, to the second, and two runs join only under the same mark. A word typed across the end of a second was two insertions ("tea[+m][+s]"), as was every second of typing in the saved file; e2e/docx-track.spec.ts failed on CI whenever "ms" was typed across one. What is typed or struck out right next to a change of the same kind by the same author now takes that change's mark: one insertion (or deletion) of when it began, as in Word. A change of another kind, someone else's change and a move are not gone on with; text taken out of what someone inserted still carries their insertion. Co-Authored-By: Claude Fable 5.2 --- src/react/docx/track.ts | 19 +++++++++++++++++-- test/track.test.ts | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/src/react/docx/track.ts b/src/react/docx/track.ts index 05c2139..9a7f3c3 100644 --- a/src/react/docx/track.ts +++ b/src/react/docx/track.ts @@ -96,17 +96,32 @@ export function trackEdit(before: Paragraph[], next: Paragraph[], pa0: string, s const inserted = N.slice(p, N.length - s) if (!removed.some(isText) && !inserted.some(isText)) return { next, sel } + // A change right next to one of the same kind by the same author goes on with it, under its mark: letters typed one + // after another are one insertion of when it began, as in Word. (Every edit comes with a mark of its own time, and + // runs join only under the same mark: a word typed across the end of a second was two insertions.) + const own = (t: Tok | undefined, k: TrackMark['k']): TrackMark | undefined => { + if (!t || !isText(t) || t.obj || !t.tc || t.tc.k !== k || t.tc.author !== mark.author || t.tc.mv) return undefined + // (a deletion of text someone inserted carries that insertion: it belongs to that text, not to the change) + const { ins: theirs, ...plain } = t.tc + return theirs ? plain : t.tc + } + const left = p > 0 ? B[p - 1] : undefined + const right = s > 0 ? B[B.length - s] : undefined + const typed = inserted.some((t) => isText(t) && !t.obj) + // what stays of the removed text: deleted marks. The author's own insertion taken out again is gone for good; // someone else's becomes a deletion, so the reviewer still sees it. Objects go for real, unless already deleted. + // (the kept text is put before the new text: the text after both is next to it only when nothing new is put in) + const del: TrackMark = own(left, 'del') ?? (typed ? undefined : own(right, 'del')) ?? { ...mark, k: 'del' } const kept: Extract[] = [] for (const t of removed) { if (!isText(t)) continue if (t.tc?.k === 'del') kept.push(t) else if (t.obj) continue else if (t.tc?.k === 'ins' && t.tc.author === mark.author) continue - else kept.push({ ...t, tc: { ...mark, k: 'del', ...(t.tc?.k === 'ins' ? { ins: t.tc } : {}) } }) + else kept.push({ ...t, tc: t.tc?.k === 'ins' ? { ...del, ins: t.tc } : del }) } - const ins: TrackMark = { ...mark, k: 'ins' } + const ins: TrackMark = (kept.length ? undefined : own(left, 'ins')) ?? own(right, 'ins') ?? { ...mark, k: 'ins' } // the paragraphs of `next`, the kept text put back where the removal was, the new text marked const paras: Extract[][] = [[]] diff --git a/test/track.test.ts b/test/track.test.ts index 5cf547d..5424e34 100644 --- a/test/track.test.ts +++ b/test/track.test.ts @@ -80,6 +80,42 @@ describe('tracking an edit', () => { const r = trackEdit(b, n, '0', caret(1, '1'), caret(1), ME) expect(r.next.map(show)).toEqual(['a[+X]', '[+Y]b']) }) + + test('what I type or strike out next to a change of mine goes on with it: one change, whatever the clock says', () => { + // (every edit is stamped with its own time: these come a second after one another) + const at = (s: number): TrackMark => ({ ...ME, date: `2026-11-08T10:00:0${s}Z` }) + const dates = (p: Paragraph) => p.runs.flatMap((r) => (r.t === 'text' && r.tc ? [r.tc.date] : [])) + const type = (p: Paragraph, o: number, text: string, mark: TrackMark) => + trackEdit([p], [para(insertText(p.runs as RRun[], o, text) as Inline[])], '0', caret(o + text.length), caret(o), mark).next[0] + const strike = (p: Paragraph, a: number, mark: TrackMark) => trackEdit([p], [para(deleteRange(p.runs as RRun[], a, a + 1) as Inline[])], '0', caret(a), caret(a + 1), mark).next[0] + + // "m", then "s" after it, then "r" before them: one insertion, of when it began + let p = type(para([t('tea')]), 3, 'm', at(0)) + p = type(p, 4, 's', at(1)) + expect([show(p), dates(p)]).toEqual(['tea[+ms]', [at(0).date]]) + p = type(p, 3, 'r', at(2)) + expect([show(p), dates(p)]).toEqual(['tea[+rms]', [at(0).date]]) + // Backspace, and again: one deletion + let d = strike(para([t('Hello')]), 4, at(0)) + d = strike(d, 3, at(1)) + expect([show(d), dates(d)]).toEqual(['Hel[-lo]', [at(0).date]]) + // typed next to a deletion of mine: an insertion of its own (a change of another kind is not gone on with), and + // what is typed after it goes on with that insertion + let both = type(strike(para([t('team')]), 3, at(0)), 3, 'x', at(1)) + expect([show(both), dates(both)]).toEqual(['tea[+x][-m]', [at(1).date, at(0).date]]) + both = type(both, 4, 'y', at(2)) + expect([show(both), dates(both)]).toEqual(['tea[+xy][-m]', [at(1).date, at(0).date]]) + + // someone else's change next to mine is theirs: mine begins a change of its own + const theirs = para([t('ab'), t('X', 'ins'), t('cd')]) + const mine = type(theirs, 3, 'Y', at(0)) + expect(mine.runs.filter((r) => r.t === 'text' && r.tc).map((r) => (r as { tc: TrackMark }).tc.author)).toEqual(['Lan', 'Vy']) + // …and so does text I take out of what someone inserted: it keeps their insertion with it + const lan = para([t('ab'), t('XY', 'ins'), t('cd')]) + const cut = strike(strike(lan, 3, at(0)), 2, at(1)) + expect(show(cut)).toBe('ab[-XY]cd') + expect(cut.runs.filter((r) => r.t === 'text' && r.tc).every((r) => (r as { tc: TrackMark }).tc.ins?.author === 'Lan')).toBe(true) + }) }) describe('accept / reject', () => { From ffc424c54c386e707bb0d3307171f526c46f2df1 Mon Sep 17 00:00:00 2001 From: "Pierre N." Date: Fri, 27 Nov 2026 15:58:14 +0700 Subject: [PATCH 3/7] test(convert): the big file written to stdout has the time it takes The 600,000-row CSV takes the engine 4.5 s on CI and more than 5 s on a slower machine, and a test has 5 s by default: there it always timed out, on CI it passed by half a second. The test now has a minute of its own. Co-Authored-By: Claude Fable 5.2 --- test/convert-service.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/convert-service.test.ts b/test/convert-service.test.ts index b9d4dbb..1b7c685 100644 --- a/test/convert-service.test.ts +++ b/test/convert-service.test.ts @@ -264,11 +264,12 @@ describe('office-convert', () => { expect(Buffer.compare(readFileSync(`${dir}/src.doc`), S('sample.doc'))).toBe(0) }) + // (the big file takes the engine 4 to 6 seconds, a test has 5 by default: the time is this test's own) test('to stdout, whole', () => { writeFileSync(`${dir}/big.csv`, bigCsv()) const r = run('big.csv', '-o', '-', '--timeout', '0') expect(r.code).toBe(0) expect(r.out.length).toBeGreaterThan(1_000_000) expect(r.out.subarray(0, 2).toString('latin1')).toBe('PK') - }) + }, 60_000) }) From f47783e56b7572ab536af7e1ee543f4b2f71993f Mon Sep 17 00:00:00 2001 From: Lptenoss Date: Tue, 1 Dec 2026 07:20:36 +0700 Subject: [PATCH 4/7] fix(docx): a tracked change goes on with one of mine only where they touch, and not with one from the file - A new deletion took the mark of my deletion after it even when the edit put a paragraph mark or a picture between them (Enter or a picture over a selection), and new text took the mark of my insertion before it when it began with a paragraph mark (a paste): the change got the date of one in another paragraph. A change goes on with the one beside it now only when nothing kept, no paragraph mark and no object comes between them. - What I typed next to an insertion of mine read from the file went on with it, with its old date and its w:id, and so did two people who never set a name (both "Me"). A change with a w:id was made before the document was opened: what is typed now is a change of its own. Co-Authored-By: Claude Opus 5.5 --- src/react/docx/track.ts | 35 +++++++++++++++++--------------- test/track.test.ts | 44 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 60 insertions(+), 19 deletions(-) diff --git a/src/react/docx/track.ts b/src/react/docx/track.ts index 9a7f3c3..b6c5d6b 100644 --- a/src/react/docx/track.ts +++ b/src/react/docx/track.ts @@ -96,32 +96,35 @@ export function trackEdit(before: Paragraph[], next: Paragraph[], pa0: string, s const inserted = N.slice(p, N.length - s) if (!removed.some(isText) && !inserted.some(isText)) return { next, sel } - // A change right next to one of the same kind by the same author goes on with it, under its mark: letters typed one - // after another are one insertion of when it began, as in Word. (Every edit comes with a mark of its own time, and - // runs join only under the same mark: a word typed across the end of a second was two insertions.) + // A change right next to one of the same kind by the same author, made since the document was opened, goes on with + // it, under its mark: letters typed one after another are one insertion of when it began, as in Word. (Every edit + // comes with a mark of its own time, and runs join only under the same mark: a word typed across the end of a second + // was two insertions.) A change read from the file has its w:id: it was made before, and what is typed now is a + // change of its own, of now, also when the author's name is the same (two people who never set one are both "Me"). const own = (t: Tok | undefined, k: TrackMark['k']): TrackMark | undefined => { - if (!t || !isText(t) || t.obj || !t.tc || t.tc.k !== k || t.tc.author !== mark.author || t.tc.mv) return undefined + if (!t || !isText(t) || t.obj || !t.tc || t.tc.k !== k || t.tc.author !== mark.author || t.tc.mv || t.tc.id !== undefined) return undefined // (a deletion of text someone inserted carries that insertion: it belongs to that text, not to the change) const { ins: theirs, ...plain } = t.tc return theirs ? plain : t.tc } const left = p > 0 ? B[p - 1] : undefined const right = s > 0 ? B[B.length - s] : undefined - const typed = inserted.some((t) => isText(t) && !t.obj) // what stays of the removed text: deleted marks. The author's own insertion taken out again is gone for good; // someone else's becomes a deletion, so the reviewer still sees it. Objects go for real, unless already deleted. - // (the kept text is put before the new text: the text after both is next to it only when nothing new is put in) - const del: TrackMark = own(left, 'del') ?? (typed ? undefined : own(right, 'del')) ?? { ...mark, k: 'del' } - const kept: Extract[] = [] - for (const t of removed) { - if (!isText(t)) continue - if (t.tc?.k === 'del') kept.push(t) - else if (t.obj) continue - else if (t.tc?.k === 'ins' && t.tc.author === mark.author) continue - else kept.push({ ...t, tc: t.tc?.k === 'ins' ? { ...del, ins: t.tc } : del }) - } - const ins: TrackMark = (kept.length ? undefined : own(left, 'ins')) ?? own(right, 'ins') ?? { ...mark, k: 'ins' } + const stays = removed.filter((t): t is Extract => isText(t) && (t.tc?.k === 'del' || (!t.obj && !(t.tc?.k === 'ins' && t.tc.author === mark.author)))) + const struck = (t: Tok | undefined) => !!t && isText(t) && t.tc?.k !== 'del' + const text = (t: Tok | undefined) => !!t && isText(t) && !t.obj + // In the paragraph, the text before the edit is followed by what stays, then by the new text (a paragraph mark or an + // object in it splits it off), then by the text after the edit: a change goes on with the one beside it only when + // they touch, with no deletion of someone else, new paragraph mark or object between them. + const del: TrackMark = + (struck(stays[0]) ? own(left, 'del') : undefined) ?? + (struck(stays[stays.length - 1]) && !inserted.length ? own(right, 'del') : undefined) ?? { ...mark, k: 'del' } + const kept = stays.map((t) => (struck(t) ? { ...t, tc: t.tc?.k === 'ins' ? { ...del, ins: t.tc } : del } : t)) + const ins: TrackMark = + (!stays.length && text(inserted[0]) ? own(left, 'ins') : undefined) ?? + (text(inserted[inserted.length - 1]) ? own(right, 'ins') : undefined) ?? { ...mark, k: 'ins' } // the paragraphs of `next`, the kept text put back where the removal was, the new text marked const paras: Extract[][] = [[]] diff --git a/test/track.test.ts b/test/track.test.ts index 5424e34..1cf4ace 100644 --- a/test/track.test.ts +++ b/test/track.test.ts @@ -81,10 +81,11 @@ describe('tracking an edit', () => { expect(r.next.map(show)).toEqual(['a[+X]', '[+Y]b']) }) + // (every edit is stamped with its own time: these come a second after one another) + const at = (s: number): TrackMark => ({ ...ME, date: `2026-11-08T10:00:0${s}Z` }) + const dates = (p: Paragraph) => p.runs.flatMap((r) => (r.t === 'text' && r.tc ? [r.tc.date] : [])) + test('what I type or strike out next to a change of mine goes on with it: one change, whatever the clock says', () => { - // (every edit is stamped with its own time: these come a second after one another) - const at = (s: number): TrackMark => ({ ...ME, date: `2026-11-08T10:00:0${s}Z` }) - const dates = (p: Paragraph) => p.runs.flatMap((r) => (r.t === 'text' && r.tc ? [r.tc.date] : [])) const type = (p: Paragraph, o: number, text: string, mark: TrackMark) => trackEdit([p], [para(insertText(p.runs as RRun[], o, text) as Inline[])], '0', caret(o + text.length), caret(o), mark).next[0] const strike = (p: Paragraph, a: number, mark: TrackMark) => trackEdit([p], [para(deleteRange(p.runs as RRun[], a, a + 1) as Inline[])], '0', caret(a), caret(a + 1), mark).next[0] @@ -116,6 +117,43 @@ describe('tracking an edit', () => { expect(show(cut)).toBe('ab[-XY]cd') expect(cut.runs.filter((r) => r.t === 'text' && r.tc).every((r) => (r as { tc: TrackMark }).tc.ins?.author === 'Lan')).toBe(true) }) + + test('a change goes on with one of mine only where they touch', () => { + const mine = (text: string, k: TrackMark['k'], s: number) => ({ ...t(text), tc: { ...at(s), k } }) as Inline + const range = (a: number, f: number) => ({ a: { pa: '0', o: a }, f: { pa: '0', o: f } }) + const b = para([t('ab'), mine('X', 'del', 0), t('e')]) + + // Enter over a selection right before a deletion of mine: the new deletion stays in the first paragraph, mine + // starts the next one + const enter = trackEdit([b], [para([t('a')]), para([mine('X', 'del', 0), t('e')], 2)], '0', caret(0, '1'), range(1, 2), at(1)).next + expect([enter.map(show), enter.map(dates)]).toEqual([['a[-b]', '[-X]e'], [[at(1).date], [at(0).date]]]) + // a picture pasted over it: the picture is between them + const img: Inline = { t: 'img', target: 'media/image1.png', w: 10, h: 10 } + const pic = trackEdit([b], [para([t('a'), img, mine('X', 'del', 0), t('e')])], '0', caret(2), range(1, 2), at(1)).next[0] + expect([show(pic), dates(pic)]).toEqual(['a[-b][-X]e', [at(1).date, at(0).date]]) + + // a paste that begins with a paragraph mark, right after an insertion of mine: the pasted text is in the next paragraph + const typed = para([t('tea'), mine('m', 'ins', 0), t('x')]) + const paste = trackEdit([typed], [para([t('tea'), mine('m', 'ins', 0)]), para([t('foox')], 2)], '0', caret(3, '1'), caret(4), at(1)).next + expect([paste.map(show), paste.map(dates)]).toEqual([['tea[+m]', '[+foo]x'], [[at(0).date], [at(1).date]]]) + + // typing over a selection right before an insertion of mine: the deletion comes first, the new text touches mine + const ins = para([t('ab'), mine('XY', 'ins', 0)]) + const over = trackEdit([ins], [para(insertText(deleteRange(ins.runs as RRun[], 1, 2), 1, 'Z') as Inline[])], '0', caret(2), range(1, 2), at(1)).next[0] + expect([show(over), dates(over)]).toEqual(['a[-b][+ZXY]', [at(1).date, at(0).date]]) + }) + + test('a change read from the file is not gone on with, even with my name on it: it was made before', () => { + const old: TrackMark = { k: 'ins', id: '12', author: 'Vy', date: '2026-10-01T09:00:00Z' } + const file = para([t('tea'), { ...t('m'), tc: old } as Inline]) + const typed = trackEdit([file], [para(insertText(file.runs as RRun[], 4, 's') as Inline[])], '0', caret(5), caret(4), at(0)).next[0] + expect([show(typed), dates(typed)]).toEqual(['tea[+m][+s]', [old.date, at(0).date]]) + expect(typed.runs.map((r) => r.tc?.id)).toEqual([undefined, '12', undefined]) + + const gone = para([t('Hell'), { ...t('o'), tc: { ...old, k: 'del' } } as Inline]) + const struck = trackEdit([gone], [para(deleteRange(gone.runs as RRun[], 3, 4) as Inline[])], '0', caret(3), caret(4), at(0)).next[0] + expect([show(struck), dates(struck)]).toEqual(['Hel[-l][-o]', [at(0).date, old.date]]) + }) }) describe('accept / reject', () => { From 1cc1694c71486509efe46323ca6794939a67a9d8 Mon Sep 17 00:00:00 2001 From: Lptenoss Date: Tue, 1 Dec 2026 07:20:36 +0700 Subject: [PATCH 5/7] test(e2e): the wait for Find's selection says what it saw when it times out Co-Authored-By: Claude Opus 5.5 --- e2e/plain.spec.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/e2e/plain.spec.ts b/e2e/plain.spec.ts index f2a908d..3a38789 100644 --- a/e2e/plain.spec.ts +++ b/e2e/plain.spec.ts @@ -66,7 +66,15 @@ test('a document beyond the browser scroll-height limit reaches, finds and edits // Find selects what it found once the scroll has come to rest, a few frames after the paragraph is in view. On a // busy machine that came after the caret was put behind the word, and the "!" replaced the word (or went by the // caret of before): the selection is awaited - await v.page.waitForFunction(() => getSelection()?.toString() === 'END_MARKER') + await v.page.waitForFunction(() => getSelection()?.toString() === 'END_MARKER', null, { timeout: 5000 }).catch(async (e) => { + const state = await v.page.evaluate(() => ({ + selection: getSelection()?.toString(), + focus: document.activeElement?.outerHTML.slice(0, 120), + matches: document.querySelector('.de-find-count')?.textContent, + top: document.querySelector('.de-scroll')?.scrollTop, + })) + throw new Error(`${e}\n${JSON.stringify(state)}`) + }) await input.press('Escape') await v.selectText('END_MARKER', 'end') await v.page.keyboard.type('!') From cb83d2ba010a66ab5ab0bf37d3117fa98f3ef9fb Mon Sep 17 00:00:00 2001 From: Lptenoss Date: Tue, 1 Dec 2026 12:30:13 +0700 Subject: [PATCH 6/7] fix(docx): a tracked change goes on with mine only when all of it touches mine Review findings: - A paste that began right next to an insertion of mine gave its old mark to all of it, also to the text past a paragraph mark or a picture it held. The new text goes on with mine now only when it is text alone. - A selection over a deletion of mine and the text after it, struck out, made a second deletion instead of going on with mine: the deletion made before inside the removal is a neighbour too, when the text struck out is of one piece. Co-Authored-By: Claude Opus 5.5 --- src/react/docx/track.ts | 24 ++++++++++++++++-------- test/track.test.ts | 10 ++++++++++ 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/react/docx/track.ts b/src/react/docx/track.ts index b6c5d6b..87f78c4 100644 --- a/src/react/docx/track.ts +++ b/src/react/docx/track.ts @@ -114,17 +114,25 @@ export function trackEdit(before: Paragraph[], next: Paragraph[], pa0: string, s // someone else's becomes a deletion, so the reviewer still sees it. Objects go for real, unless already deleted. const stays = removed.filter((t): t is Extract => isText(t) && (t.tc?.k === 'del' || (!t.obj && !(t.tc?.k === 'ins' && t.tc.author === mark.author)))) const struck = (t: Tok | undefined) => !!t && isText(t) && t.tc?.k !== 'del' - const text = (t: Tok | undefined) => !!t && isText(t) && !t.obj - // In the paragraph, the text before the edit is followed by what stays, then by the new text (a paragraph mark or an - // object in it splits it off), then by the text after the edit: a change goes on with the one beside it only when - // they touch, with no deletion of someone else, new paragraph mark or object between them. + const text = (t: Tok) => isText(t) && !t.obj + // In the paragraph, the text before the edit is followed by what stays (deletions made before, and the text struck + // out now), then by the new text, then by the text after the edit. A change goes on with the one beside it only when + // all of it touches that one: the text struck out is of one piece (no deletion made before in it), the new text is + // text only (a paragraph mark or an object splits it), and nothing else is between them. + let first = -1 + let last = -1 + stays.forEach((t, i) => { + if (!struck(t)) return + if (first < 0) first = i + last = i + }) + const piece = first >= 0 && stays.slice(first, last + 1).every(struck) const del: TrackMark = - (struck(stays[0]) ? own(left, 'del') : undefined) ?? - (struck(stays[stays.length - 1]) && !inserted.length ? own(right, 'del') : undefined) ?? { ...mark, k: 'del' } + (piece ? own(first > 0 ? stays[first - 1] : left, 'del') ?? own(last < stays.length - 1 ? stays[last + 1] : inserted.length ? undefined : right, 'del') : undefined) ?? + { ...mark, k: 'del' } const kept = stays.map((t) => (struck(t) ? { ...t, tc: t.tc?.k === 'ins' ? { ...del, ins: t.tc } : del } : t)) const ins: TrackMark = - (!stays.length && text(inserted[0]) ? own(left, 'ins') : undefined) ?? - (text(inserted[inserted.length - 1]) ? own(right, 'ins') : undefined) ?? { ...mark, k: 'ins' } + (inserted.length && inserted.every(text) ? own(stays.length ? stays[stays.length - 1] : left, 'ins') ?? own(right, 'ins') : undefined) ?? { ...mark, k: 'ins' } // the paragraphs of `next`, the kept text put back where the removal was, the new text marked const paras: Extract[][] = [[]] diff --git a/test/track.test.ts b/test/track.test.ts index 1cf4ace..b37cb0b 100644 --- a/test/track.test.ts +++ b/test/track.test.ts @@ -136,6 +136,16 @@ describe('tracking an edit', () => { const typed = para([t('tea'), mine('m', 'ins', 0), t('x')]) const paste = trackEdit([typed], [para([t('tea'), mine('m', 'ins', 0)]), para([t('foox')], 2)], '0', caret(3, '1'), caret(4), at(1)).next expect([paste.map(show), paste.map(dates)]).toEqual([['tea[+m]', '[+foo]x'], [[at(0).date], [at(1).date]]]) + // …or that holds one, or a picture: only part of it would touch mine, it is a change of its own + const two = trackEdit([typed], [para([t('tea'), mine('m', 'ins', 0), t('foo')]), para([t('barx')], 2)], '0', caret(3, '1'), caret(4), at(1)).next + expect([two.map(show), two.map(dates)]).toEqual([['tea[+m][+foo]', '[+bar]x'], [[at(0).date, at(1).date], [at(1).date]]]) + const pictured = trackEdit([typed], [para([t('tea'), mine('m', 'ins', 0), t('foo'), img, t('barx')])], '0', caret(8), caret(4), at(1)).next[0] + expect([show(pictured), dates(pictured)]).toEqual(['tea[+m][+foo][+bar]x', [at(0).date, at(1).date, at(1).date]]) + + // a selection over a deletion of mine and the letter after it, struck out: the letter goes on with my deletion + const struck = para([t('ab'), mine('X', 'del', 0), t('cd')]) + const over2 = trackEdit([struck], [para(deleteRange(struck.runs as RRun[], 2, 4) as Inline[])], '0', caret(2), range(2, 4), at(1)).next[0] + expect([show(over2), dates(over2)]).toEqual(['ab[-Xc]d', [at(0).date]]) // typing over a selection right before an insertion of mine: the deletion comes first, the new text touches mine const ins = para([t('ab'), mine('XY', 'ins', 0)]) From 7c14b4b721bfbf851cb83fa5a33c155e911314e4 Mon Sep 17 00:00:00 2001 From: Lptenoss Date: Tue, 1 Dec 2026 12:30:13 +0700 Subject: [PATCH 7/7] test(convert): the command line run by the tests is stopped after a minute spawnSync holds the thread, so a test's own time could not stop a conversion that hung: the suite hung with it. Co-Authored-By: Claude Opus 5.5 --- test/convert-service.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/convert-service.test.ts b/test/convert-service.test.ts index 1b7c685..3a18922 100644 --- a/test/convert-service.test.ts +++ b/test/convert-service.test.ts @@ -230,8 +230,9 @@ describe('office-convert', () => { const dir = mkdtempSync(`${tmpdir()}/office-convert-`) afterAll(() => rmSync(dir, { recursive: true, force: true })) const CLI = `${import.meta.dir}/../packages/convert/src/cli.ts` + // (spawnSync holds the thread: a test's own time can't stop it, the process is stopped instead) const run = (...args: string[]) => { - const p = Bun.spawnSync(['bun', CLI, ...args], { cwd: dir }) + const p = Bun.spawnSync(['bun', CLI, ...args], { cwd: dir, timeout: 60_000 }) return { code: p.exitCode, err: p.stderr.toString(), out: p.stdout } }