Description
A second edit to a paragraph, sent while an earlier conversion of the same paragraph is still in flight, never gets its own conversion applied. The saved file is right; the editor keeps the old look and the toolbar the old state.
Reproduction:
- Open
sample.docxfor editing and select text in a body paragraph. - Click "Bulleted list", then press Ctrl+Alt+2 (Heading 2) before the first
docx.editresponse arrives. A slow worker on a large document, key repeat or programmatic calls get there; in a test, hold the first response. - The toolbar size stays 11 and the paragraph renders at 11pt. The saved / reopened file has Heading 2 at 13pt.
- The paragraph stays in
staleuntil it is edited again.
Unit variant: toggleList('bullet') followed by setPara({ align: 'center' }) ends with a last notification of align: 'left' and busy: true, while the saved file is centred.
Reproduced in Chromium with a real worker and in a DocxEditor probe while reviewing #22.
Cause, on main at 43b28d6:
- The first response's marker loop replaces the paragraph object with
put():
office-engine/src/react/docx/DocxEditor.ts
Lines 700 to 708 in 43b28d6
// list numbering changes anywhere in the document for (const [k, m] of Object.entries(res.markers)) { for (const loc of this.locate(Number(k))) { const p = loc.list[loc.index] as Paragraph if ((loc.list[loc.index - 1] as Paragraph | undefined)?.pid === p.pid) continue this.put(loc.pa, { ...p, marker: m ? { text: m.text, s: m.s, tab: m.tab } : undefined, lst: m?.lst }) touched = true } } - The second response then fails the
cur.includes(x)identity check against its ownsentset and is skipped as "edited again", although no later edit exists that would ask for the conversion:
office-engine/src/react/docx/DocxEditor.ts
Lines 683 to 686 in 43b28d6
// edited again: the paragraph stays `stale`, so that edit asked for the conversion too and its answer is the one applied let again = false for (const x of sent) again ||= x.pid === pid && cur.length > 0 && !cur.includes(x) if (again) continue
Expected: the conversion of the latest edit is applied and the formatting state is republished, whatever an earlier response did to the paragraph object in between.
Possible direction: let the "edited again" check survive a replacement made by the marker loop (the rebuilt loop records its replacements in heir, the marker loop does not), or compare by something other than object identity. A delayed-response test with two overlapping edits on one paragraph would cover it.
Activity