Commit Graph
29 Commits
Author SHA1 Message Date
Jonathan Kelley c73dc43233 fix(autofmt): add support for handling comments in various expression types (#5461)
* fix(autofmt): add support for handling comments in various expression types

* fmt
2026-04-07 16:19:00 -07:00
John CostaandJonathan Kelley e5b9c39f4e fix(autofmt): remove extra whitespace before commas in for-loop tuple patterns (#5384)
* fix(autofmt): remove extra whitespace before commas in for-loop tuple patterns

`dx fmt` was adding spaces before commas in for-loop destructuring
patterns (e.g. `for (index , name , value)`) because `TokenStream::Display`
inserts spaces between every token. Route the pattern through prettyplease
via a new `unparse_pat` helper, following the existing `unparse_expr` pattern.

Fixes #5348

* style: apply rustfmt to writer.rs

---------

Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
2026-03-27 17:15:32 -07:00
hideselfviewandDmitry Minkovsky 3a60140dff fix: prevent dx fmt from adding trailing whitespace to blank lines (#5224)
This fixes a conflict between dx fmt and cargo fmt (rustfmt). Previously,
dx fmt would add indentation whitespace to blank lines inside RSX blocks,
but cargo fmt removes trailing whitespace from all lines. This made it
impossible for code to satisfy both formatters.

The fix skips adding indentation to empty lines in two places:
1. When indenting formatted RSX blocks inside expressions
2. When reassembling the final formatted output

Fixes #5223

Co-authored-by: Dmitry Minkovsky <dminkovsky@gmail.com>
2026-01-16 15:47:47 -08:00
Jonathan Kelley db23197925 fix dx fmt span attribute issue (#5132)
* fix: if expr spans causing invalid span locations

* cleanups

* clippy, typo
2025-12-25 16:50:50 -05:00
Jonathan Kelley c21b44a4e6 fix collapsing of multiline components and rsx!{} calls (#2849) 2024-08-15 17:03:58 -07:00
Jonathan Kelley 851abe82d5 Fix non-brace delimeters in nested macro formatting (#2831) 2024-08-13 22:47:43 -07:00
Jonathan Kelley 828cc502f1 Fix: #2604, Fix: #2240, Fix: #2341, Fix #1355 - Better error handling and and spaces handling in autofmt (#2736)
* add new autofmt sample
* Feat: implement rustfmt::skip support for rsx
* generally improve error handling with better expect messages
* wip: nested rsx formatting and expression formatting
* nested rsx formatting works
* collapse autofmt crate
* cast indent through macros
* use proper whitespace
* no more eating comments!
* Use proper error handling
2024-07-30 18:36:13 -07:00
Jonathan Kelley b30810e486 cut out a number of changes from the hr PR (#2580) 2024-07-02 17:09:57 -07:00
Jonathan Kelley 67af2d89dd Autofmt nested rsx using syn::Visitor (#2279)
* Nested macros using visitor pattern
2024-04-08 22:15:52 -07:00
Jonathan Kelley be99e29e5f Fixes to autofmt, make it more aggressive (#2230)
* fix: fmt unterminated if, be more aggressive with line splits

* Fix: Handle long exprs in for/if statements
2024-04-03 15:27:36 -07:00
Jonathan Kelley d8942a255b Fix #2104: fmt incorrectly using 1-indexing for columns (#2106)
* Fix #2104: fmt incorrectly using 1-indexing for columns

* Clippy...
2024-03-18 18:23:45 -07:00
Alex Parrill 52fb080193 Use indentation settings in dx fmt and vscode extension
Adds the ability to specify an indent string to public autofmt methods - either
a sequence of spaces or a tab character.

Get the indentation style and size from rustfmt for dx fmt, or from the editor
settings for the vscode extension.

Closes #1595
2023-11-01 17:24:18 -04:00
Evan Almloff d9e0b9a918 fix autoformatting raw strings 2023-06-02 12:03:56 -05:00
Jonathan Kelley 4e4e101eee fix: dont choke on emojji n exprs 2023-01-17 16:24:29 -08:00
Jonathan Kelley b81eca0433 fix: short expr lists should not eat the final exprs 2023-01-16 17:25:55 -08:00
Jonathan Kelley b6e4db1f2f fix: immediate exprs 2023-01-16 16:36:50 -08:00
Jonathan Kelley 3945928c59 fix: adjust padding on autofmt 2023-01-13 17:16:06 -08:00
Jonathan Kelley ac6035cb2a feat: parse entire file instead of hunting for verbtain 2023-01-13 16:46:34 -08:00
Jonathan Kelley 6cd87796f2 feat: allow ifchains and for loops 2023-01-13 10:51:12 -08:00
Jonathan Kelley 293ef9c690 fix: only flow exprs with indent in mind 2023-01-12 17:02:41 -08:00
Jonathan Kelley 983789e4c5 handle weird trailing whitespace in autofmt 2023-01-12 16:55:13 -08:00
Jonathan Kelley cc8b910cf3 fix emoji support in autofmt 2023-01-12 16:29:31 -08:00
Jonathan Kelley 74421d47fd fix comments being eaten in autofmt 2023-01-07 14:09:32 -08:00
Jonathan Kelley 181a51a63b wip: add whitespace parsing to rsx 2022-09-30 10:51:53 -07:00
Jonathan Kelley 5313fc0cc6 fix: trailing commas with key 2022-09-28 17:06:11 -07:00
Jonathan Kelley a37458b9fa chore: fixes to autoformat to prevent double rendering of expr line 2022-09-28 16:47:10 -07:00
Jonathan Kelley 251aafa5fd fix: fmting 2022-07-05 18:42:00 -04:00
Jonathan Kelley 19e6e43358 fix: only apply comments if relevant 2022-07-05 17:59:33 -04:00
Jonathan Kelley fa9ebe17cc feat: fix autoformatting around one liners 2022-07-05 17:49:16 -04:00