Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

diff-friendly formatting? #37

Open
gussmith23 opened this issue Jul 23, 2022 · 1 comment
Open

diff-friendly formatting? #37

gussmith23 opened this issue Jul 23, 2022 · 1 comment

Comments

@gussmith23
Copy link

I use fmt all the time, and it rocks -- perhaps the only thing that bugs me is that the diffs after formatting can be huge, even after I change just a single line. For example, if I change a line such that it becomes longer than the max line length, it will get wrapped, which can cause a change of indentation in the rest of the scope. Is there any way around this?

@sorawee
Copy link
Owner

sorawee commented Jul 23, 2022

Can you post an example file before and after you make the change? (Slack is fine too, if you don't want to disclose the source file publicly).

In general, Racket is different from other languages in that it heavily uses dynamic alignment. For example, you would indent with 5 spaces in:

(foo arg1
     arg2
     arg3
     arg4)

where 5 = 1 (from lparen) + 3 (from foo) + 1 (from space). It's dynamic because foo is dynamic content.

So if you change foo to something else, reformatting could affect a lot of lines.

C-like languages have static alignment, and I suspect that the diff would be smaller as a result.

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

No branches or pull requests

2 participants