Skip to content

Remove empty line at start of fun dec #723

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

Merged
merged 1 commit into from
Jan 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
auto-save edits in general (Code -> Saving -> Auto-Save), e.g. on idle editor
or focus loss, so this feature becomes less relevant. (#631).
- blank lines in function calls and headers are now removed, for the former only
when there are no comments before or after the blank line (#629, #630, #635).
when there are no comments before or after the blank line (#629, #630, #635,
#723).
- speed improvements: ~10% when cache is activated because transformers are not
captured as character anymore (#679), ~3% in low-level optimization (#691).
7% by requiring magrittr 2.0 (#681), ~8% by dropping unused transformers
Expand Down
2 changes: 1 addition & 1 deletion R/rules-line-breaks.R
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ remove_line_break_before_round_closing_after_curly <- function(pd) {

remove_line_breaks_in_fun_dec <- function(pd) {
if (is_function_dec(pd)) {
round_after <- pd$token == "')'" & pd$token_before != "COMMENT"
round_after <- (pd$token == "')'" | pd$token_before == "'('") & pd$token_before != "COMMENT"
pd$lag_newlines[pd$lag_newlines > 1L] <- 1L
pd$lag_newlines[round_after] <- 0L
}
Expand Down
13 changes: 13 additions & 0 deletions tests/testthat/fun_dec/line_break_fun_dec-in.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,16 @@ a <- function(x,
y) {
x - 1
}


a <- function(
x,
y) {
x - 1
}

a <- function( #
x,
y) {
x - 1
}
83 changes: 63 additions & 20 deletions tests/testthat/fun_dec/line_break_fun_dec-in_tree

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions tests/testthat/fun_dec/line_break_fun_dec-out.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,15 @@ a <- function(x,
y) {
x - 1
}


a <- function(x,
y) {
x - 1
}

a <- function( #
x,
y) {
x - 1
}