Skip to content

extradoc: named-range index staleness corrupts colbreak/equation position on in-place paragraph edit #68

@sripathikrishnan

Description

@sripathikrishnan

Summary

When a paragraph containing an inline passthrough element (colbreak, equation, rich link) is edited in-place, the named-range marker for that element retains its original base-document index. After the text edit is applied, that index is stale — the element moves to the wrong position or disappears.

Root Cause

The reconciler (reconcile_v3/lower.py::_lower_story_content_update) emits a text update (deleteContentRange + insertText) for the paragraph but has no mechanism to adjust named-range indices by the text delta. Named-range markers (serialized as <x-colbreak/>, <x-eq/> etc. in markdown) are treated as opaque passthrough with fixed base-coordinate indices.

After the text edit:

  • The Google Docs API shifts content at indices > edit point
  • Our named-range re-creation request still uses the pre-edit index
  • Result: the colbreak/equation lands at the wrong position

Current Status

Confirmed broken. test_sample3_bugs.py::test_bug65_colbreak_preserved_on_columns_text_edit is xfail(strict=True).

Fix Direction

In lower.py, when emitting in-place paragraph updates:

  1. Scan desired document named ranges overlapping the paragraph's index range
  2. For each such named range (colbreak, equation, etc.), compute the text delta from the edit
  3. Adjust the named-range index by the delta, or schedule a deleteNamedRange + re-create at the adjusted position

This is a design gap — the reconciler currently has no cross-cutting view of named-range indices vs. text edit deltas.

Impact

Any document with column breaks, equations, or rich links inside paragraphs that are edited (text changed but paragraph matched by the DP). Invisible corruption — no error is raised.

Related

  • Failure mode described in extradoc/docs/diff-system-review.md (Section 3.2, Scenario A)
  • The opposite case — unedited paragraphs with named ranges — is safe; only in-place edits trigger this

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions