-
Notifications
You must be signed in to change notification settings - Fork 93
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
Range formatting always adds indention when the range has initial indention #264
Comments
It seems that we will need to check if a line is a part of a string and opt-out of the reindentation. |
Looks like we could use a trick like the following: style_fun <- function() {
styler::tidyverse_style(indent_by = 4)
}
styler::style_text('{
data <- dbQuery(
con,
"select name, group, max(update_time) as max_time
from users
where date = 20200525
group by group"
)
}', style = style_fun) We put the code being formatted inside a |
Sorry, it won't work properly if there are nested blocks inside the expression since the |
Looks like we could tweak the style function like the following to apply initial indention to the expression style_fun <- function() {
s <- styler::tidyverse_style(indent_by = 2)
s$indention$apply_initial_indention <- function(pd_nested) {
print(pd_nested)
# do something with pd_nested to add indention to expressions
pd_nested
}
s
} |
Perform range formatting on the following code and it works well.
However, it does not work well when the selection has initial indention like the following:
Once:
Twice:
More times:
This is particular annoying if on-type-formatting triggers range formatting inside the function like above.
The text was updated successfully, but these errors were encountered: