-
Notifications
You must be signed in to change notification settings - Fork 440
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
fmt creates less-than-ideal indentation #278
Comments
I have one more example that involve function calls.
|
I also want to revisit the enforced alignment of parameters to a function with the open parenthesis "(" Example
What is the reaction to allow another type of alignment?
Instead of getting aligned with the "(" we prefer to be indented from the start of the statement. What do you think ? |
We really like the automated formatting idea and would like to use it more extensively. I can spend some free time on these issues if you could give some pointers. Maybe a similar previous PR, a test that exercises the relevant path ? |
I've been thinking about this, but I haven't had time to dive into the code yet. The examples you've given do look bad and everything you're asking for is reasonable. I recall the logic involved (formatter.cpp FixIndentation class) is fairly complex. The case of
should definitely not be happening because it should only line up if the first param is on the same line, otherwise it should indent by only 4 (or whatever you set). |
So I verified the function parameters problem, not sure why it's doing it but I think it will be an easy fix since it's designed to do what you want, it's probably just a typo or something. Your original case (3) is questionable because if you have it do this:
Then this pattern would also be indented and I don't think we want that:
So unless we have a special behavior for The case (2) is behaving the same as (3). We could try to make it understand the fact that the
|
Ok the function parameters problem is fixed in #290. The others need more thinking. |
Thanks looks good. |
How do you feel about
|
I prefer:
[
object,
object2 if condition,
]
:)
On Jan 24, 2017 4:39 PM, "Dave Cunningham" <[email protected]> wrote:
How do you feel about
// 1)
{
objects():: [object]
+ if condition then [object2]
else [],
}
// 2)
{
objects():: [object]
+ if condition then
[object2]
else [],
}
// 3)
{
objects():: [object] + if condition then
[object2]
else [],
}
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#278 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ADUzzHedMAakdsk1eE7jUxbtcY3ZVsTqks5rVpnLgaJpZM4LcWxN>
.
|
Uh huh :) Seriously, if addition of that feature would make a more significant difference then it could be prioritized... |
These all look good to me. Thanks for your attention. We have a quite large jsonnet code base now with all the weird combinations of arrays, objects, conditions, etc. With that experiment I may know more about the style improvements. |
I don't really love any of the three. If there was an inline conditional like we've discussed in #234 I think a lot of these cases would go away. @ahakanbaba we may want to look into adding something to util that filters nulls out of an array so we can avoid a lot of this optional concatenation into an array (and thereby mess up ordering of elements). |
I feel like the discussion is diverging here a little bit. We are talking about indentation of the currently existing conditional. If you do not like indentations in #278 (comment) do you have better suggestions? Even tough there is a plan for a syntax like
The indentations for the current if conditions should be fixed. |
Hi,
I ran into several cases where the auto formatter does not display the code in a reasonable ways.
Here are some examples.:
I am using the the "-i -n 4 " options to fmt via vim-jsonnet.
Can be seen here
https://github.com/google/vim-jsonnet/blob/master/autoload/jsonnet.vim#L83
It would be great to improve these.
The text was updated successfully, but these errors were encountered: