Skip to content

fix(autofmt): stop dx fmt --all-code from duplicating and truncating … - #5816

Open
chairulakmal wants to merge 1 commit into
DioxusLabs:mainfrom
chairulakmal:fix-5682-allcode-corruption
Open

fix(autofmt): stop dx fmt --all-code from duplicating and truncating …#5816
chairulakmal wants to merge 1 commit into
DioxusLabs:mainfrom
chairulakmal:fix-5682-allcode-corruption

Conversation

@chairulakmal

Copy link
Copy Markdown

…closure bodies

Fixes #5682.

dx fmt --all-code runs the file through prettyplease before formatting the rsx! bodies, and prettyplease often wraps a closure in the middle of its signature. write_partial_expr then reads the wrapped line as a hand-written method chain, copies it out verbatim, and re-emits the lines after it, so the closure body comes out duplicated and truncated and the file no longer compiles.

This narrows that part of the code to only take over when the source it copied matches the formatter output it replaces exactly.

Swept over every .rs file in examples/ and packages/: plain dx fmt output does not change, and the 24 files that --all-code corrupts today (20 of them into text syn cannot parse) all format cleanly with this change.

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.

Running dx fmt --all-code corrupts my code's syntax

1 participant