Skip to content

Preserve tab stop references when changing position - #1647

Open
FFspiky wants to merge 1 commit into
python-openxml:masterfrom
FFspiky:fix/preserve-tab-stop-references
Open

FFspiky wants to merge 1 commit into
python-openxml:masterfrom
FFspiky:fix/preserve-tab-stop-references

Conversation

@FFspiky

@FFspiky FFspiky commented Nov 17, 2026

Copy link
Copy Markdown

Changing TabStop.position replaces its XML node. If two references were obtained for that tab stop, moving one leaves the other attached to the removed node: setting a dot leader through the earlier reference silently loses that change when the document is saved. The moved proxy's .element also continues to refer to the removed node.

Reinsert the existing node in position order, using the same ordering helper for new and moved tab stops. Existing references then see the new position and continue to modify the document. Tests cover node identity, negative positions, ties, and persistence of a leader edit through an earlier reference after saving and reopening the document. Seven regression cases fail on master e454546 and pass with the fix.

Validation on macOS arm64 / Python 3.13.2:

  • python -m pytest -q: 1,611 passed.
  • python -m behave --format progress --stop --tags=-wip: 650 scenarios / 1,856 steps passed.
  • Ruff, source/wheel build and git diff --check pass.
  • Targeted Pyright is not clean on master (185 diagnostics) or this patch (161); these files still contain untyped legacy APIs.

The test environment uses pytest 8.4.2 and pyparsing 3.2.3, which satisfy the declared development dependencies. Installing pyparsing 3.3.3 instead causes an existing deprecated delimitedList call in the test helper to fail collection under warnings-as-errors. Other platforms and Word rendering were not tested.

AI disclosure: OpenAI Codex investigated the bug, prepared and reviewed the patch, and ran the reported checks.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant