-
Notifications
You must be signed in to change notification settings - Fork 11
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
Wrapping at infix operator in long if statement chain #234
Comments
Smaller reprex: # before
if (x %in% letters && this_needs_to_be_long_enough && this_also_needs_to_be_long_enough) {
'result'
}
# after
if (
x %in%
letters &&
this_needs_to_be_long_enough &&
this_also_needs_to_be_long_enough
) {
'result'
} |
hmm I think this is to be expected? |
This seems inconsistent # before
if (x %in% letters && y %in% some_other_collection_of_letters && x == who_knows_what) {
'result'
}
# after
if (
x %in%
letters &&
y %in% some_other_collection_of_letters &&
x == who_knows_what
) {
'result'
} |
Out of the box, if (
domain %in% private$session$get_auto_events() &&
private$event_callback_counts[[domain]] == 1 &&
isTRUE(private$event_enable_domains[[domain]])
) {
private$session$debug_log("Enabling events for ", domain)
private$session[[domain]]$enable()
} and the smaller reprex: # before
if (
x %in% letters &&
this_needs_to_be_long_enough &&
this_also_needs_to_be_long_enough
) {
"result"
}
# after
if (
x %in% letters &&
this_needs_to_be_long_enough &&
this_also_needs_to_be_long_enough
) {
"result"
} Check out |
+1 for no break after infix operators. The break makes the lhs and rhs look like operands, esp. mixed with |
@kpagacz tergo formats this similar to air with # before
if (x %in% letters && this_needs_to_be_long_enough && this_also_needs_to_be_long_enough) {
'result'
}
# after (tergo)
if (
x %in%
letters &&
this_needs_to_be_long_enough &&
this_also_needs_to_be_long_enough
) {
'result'
}
# after (air)
if (
x %in%
letters &&
this_needs_to_be_long_enough &&
this_also_needs_to_be_long_enough
) {
'result'
} # before
if (x %in% letters && y %in% some_other_collection_of_letters && x == who_knows_what) {
'result'
}
# after (tergo)
if (
x %in%
letters &&
y %in%
some_other_collection_of_letters &&
x ==
who_knows_what
) {
'result'
}
# after (air)
if (
x %in%
letters &&
y %in% some_other_collection_of_letters &&
x == who_knows_what
) {
'result'
} # With `line_length = 80`
tergo ~/Desktop/test2.R ~/Desktop/tergo.toml |
@jayhesselberth |
Yeah, maybe |
I have other examples of this. Formatted: tibble(
tmdb_production_company_name = res$production_companies[[1]]$name,
tmdb_production_company_country = res$production_companies[[
1
]]$origin_country
)
new_var_with_very_long_name_to_cause_overflow <- (1.2382 +
20.3402 +
12120.3402 * 2) /
sqrt(20.3920^2 + 5.1292^2) My preference would be for it to look something like tibble(
tmdb_production_company_name = res$production_companies[[1]]$name,
tmdb_production_company_country =
res$production_companies[[1]]$origin_country
)
new_var_with_very_long_name_to_cause_overflow <-
(1.2382 + 20.3402 + 12120.3402 * 2) /
sqrt(20.3920^2 + 5.1292^2) I think a general rule would be to see if you could fit in a new line, to not fully expand? |
Just bumped into this in the wild (i.e. code I didn't write in chromote). I expected no change to the following code,
but
air format
introduces a line break after the%in%
:It's not a new change, this repros back to air 0.1.1.
The text was updated successfully, but these errors were encountered: