-
Notifications
You must be signed in to change notification settings - Fork 71
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
Indendation of low-precedence infix operators #1150
Comments
The style guide doesn't really say much about indentation. Perhaps we could raise that; meanwhile, editing code that doesn't violate anything in the style guide generally goes against styler's intention, right? |
Note that styler::style_text("
y +
x1 +
x2
")
#> y +
#> x1 +
#> x2 Created on 2023-09-15 with reprex v2.0.2 |
I think "should"/"shouldn't" can only be ruled by the style guide (for our defaults, at least). If the style guide is silent and we're trying to be consistent, we should come to an agreement after discussion. Reasoning in terms of "mixed precedence" makes sense to me. There's a related styler issue I've raised: tidyverse/style#160. |
I can add the following similar example that yields malformed code (the input is the correctly formatted code that I would expect). > styler::style_text("
+ stats::model.matrix(
+ ~ a
+ + b
+ + c,
+ dd
+ )
+ ")
stats::model.matrix(
~ a
+ b
+ c,
dd
) Note that considerations around the operator precedence do not apply here since they don't actually function as mathematical operators in this context. I believe something similar may arise around the EDIT: stats::model.matrix(~ a
+ b
+ c,
dd) |
I don’t think we can differentiate these cases here in styler. Also, the issue caused some headache already in the past and I can’t recall the reasons for tie current implementation and if your representative was intentional or not (but it could probably be for d searching the issues) and given that the style guide is silent on it and the syntax is generally not used very often, this has low priority for me. |
Related to: r-lib/lintr#1718
Has parse tree
~(y, +(x1, x2))
so the~
ends in line 3 and should thus cause an indentation for lines 2 and 3.+
ends in line 3 and should cause another level of indentation on line 3.Created on 2023-09-15 with reprex v2.0.2
The text was updated successfully, but these errors were encountered: