Skip to content

Mark added and removed TOML table sections - #183

Open
Liyu0310-Code wants to merge 1 commit into
trailofbits:masterfrom
Liyu0310-Code:fix/toml-section-edit-markup
Open

Mark added and removed TOML table sections#183
Liyu0310-Code wants to merge 1 commit into
trailofbits:masterfrom
Liyu0310-Code:fix/toml-section-edit-markup

Conversation

@Liyu0310-Code

Copy link
Copy Markdown

Fixes #179.

TOMLFormatter.print_MappingNode synthesized [table] section headers from the parent mapping's key segments and printed section bodies from the value mapping's own children, so the Remove / Insert edit on a section's key/value pair had no node to wrap — a whole added or removed [table] rendered with no edit markup while the exit status still reported a difference.

TOMLMapping now tracks whether its section was removed or inserted (propagating through pure-container mappings, whose falsy skip would otherwise drop the flag), and the section writer applies the same markup contexts that Remove.print / Insert.print use — red background + strike and green background + under-plus, with the ~~ / ++ fallbacks when ANSI color is disabled. Section emission is factored into TOMLFormatter._write_section so those contexts can wrap it.

Testing

  • Added regression tests: a removed table, an inserted table, and a removed nested table now render with ~~ / ++ markers, and unchanged documents still render without markers.
  • Rendered output for documents without edits is byte-identical to master.
  • Full suite: 186 passed; the 3 failing tests fail identically on unmodified master on this machine (enumerated and compared).

Disclosure

This PR was generated by an AI coding agent operated by @Liyu0310-Code; the account owner does not review code. Happy to iterate on any feedback.

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.

Adding or removing a whole TOML table renders with no edit markup

1 participant