Skip to content

fix: preserve comments when set_array updates existing arrays - #75

Merged
tylerbutler merged 3 commits into
mainfrom
tylerbutler-tomlet-issue-64
Nov 7, 2026
Merged

tylerbutler merged 3 commits into
mainfrom
tylerbutler-tomlet-issue-64

Conversation

@tylerbutler

@tylerbutler tylerbutler commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

set_array replaced entire arrays and discarded their internal comments, including during no-op policy updates. This preserves comments for unchanged items without adding a public API.

Approach

  • Return the original document for semantic no-op updates, preserving exact source and line endings.
  • Capture array-item and closing trivia during parsing. Reuse unchanged items, including their lexical forms, and match duplicate values one occurrence at a time in their original order.
  • Retain standalone closing comments. Remove comments attached to removed or replaced items, as agreed for this fix.
  • Preserve nested array source inside inline tables, handle Unicode and multiline quote boundaries, and use stack-safe matching on JavaScript.

Includes API documentation, README guidance, and a changelog fragment. Public types and edit errors remain unchanged.

Closes #64

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Changelog check

package fragments version
tomlet ✅ 1 1.4.1 → 1.4.2

Release preview

tomlet 1.4.1 → 1.4.2

v1.4.2 - 2026-11-07

Fixed

  • Preserve comments and lexical forms for unchanged array items during set_array edits; keep exact source for no-op updates. Handle Unicode trivia and multiline string boundaries on both targets, and prevent JavaScript stack overflow when editing large arrays.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Failed ❌

View logs ↗
52b6147 2026-11-07T01:14:05.440Z View logs ↗
  • Build: Failed ❌

View logs ↗
31035cd 2026-11-07T01:10:26.469Z View logs ↗

@tylerbutler tylerbutler changed the title Preserve comments when set_array updates existing arrays fix: preserve comments when set_array updates existing arrays Nov 7, 2026
@tylerbutler
tylerbutler merged commit efaaf77 into main Nov 7, 2026
7 of 8 checks passed
@tylerbutler
tylerbutler deleted the tylerbutler-tomlet-issue-64 branch November 7, 2026 01:16
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.

Preserve comments inside arrays when set_array updates a value

1 participant