Skip to content

DOCX: a second edit sent before the first conversion returns loses its own conversion #26

Open

Description

@pierreneter

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:

  1. Open sample.docx for editing and select text in a body paragraph.
  2. Click "Bulleted list", then press Ctrl+Alt+2 (Heading 2) before the first docx.edit response arrives. A slow worker on a large document, key repeat or programmatic calls get there; in a test, hold the first response.
  3. The toolbar size stays 11 and the paragraph renders at 11pt. The saved / reopened file has Heading 2 at 13pt.
  4. The paragraph stays in stale until 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():
    // 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 own sent set and is skipped as "edited again", although no later edit exists that would ask for the conversion:
    // 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions