fix(config_edit): byte-clean writes matching Loxone's format - #13
Open
tobsch wants to merge 1 commit into
Open
Conversation
Every write re-serialized the whole file, so a raw `diff` on a `.Loxone` reported ~11.5k changed lines for a single added block — real changes drowned in formatting noise, making review impossible. The churn was purely emitter formatting that differs from Loxone's own output. Match it so a round-trip touches only what actually changed: - `pad_self_closing(false)` — Loxone writes `<C/>`, xml-rs padded to `<C />` (this alone caused ~99.5% of the diff). - Expand attribute-less empty tags: Loxone writes `<IoData></IoData>`, never `<IoData/>` (attributed empties like `<Co K="I" U="…"/>` stay self-closed). Verified: the config has 45 `<IoData></IoData>` and zero attribute-less `<X/>`. - Un-escape `
` → literal newline in attribute values (multi-line PicoC code, notification texts). Loxone keeps literal newlines and never emits `
`, so this only reverses xml-rs's own escaping. - Restore the trailing newline. Result: adding one block now produces a diff of exactly that block (+6/-0) instead of 11.5k lines. All 78 config_edit tests pass; adds a formatting round-trip test. Fixes eisber#7 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V1TT6BSmf3uXakmtfexfDt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7.
Problem
Every write re-serialized the whole file. A raw
diffon the resulting.Loxonereported ~11,500 changed lines for a single added block — the real change was drowned in formatting noise, so changes couldn't be reviewed before uploading to a live house.The churn was purely emitter formatting that differs from Loxone's own output — the content was identical, just re-emitted differently.
Fix
Make
to_bytesmatch Loxone's on-disk conventions so a round-trip touches only what actually changed:pad_self_closing(false)— Loxone writes<C/>, xml-rs padded to<C />. This alone was ~99.5% of the diff (every self-closing element).<IoData></IoData>, never<IoData/>; attributed empties like<Co K="I" U="…"/>stay self-closed. (In the test config: 45<IoData></IoData>, zero attribute-less<X/>— a consistent rule.)
→ literal newline in attribute values (multi-line PicoC code, notification/alarm texts). Loxone keeps literal newlines and never emits
, so this only reverses xml-rs's own escaping.Result
A diff of exactly the added block (+6/-0) — raw
.Loxonediffs are now reviewable.config_edittests pass; adds a formatting round-trip test.🤖 Generated with Claude Code