Skip to content

Commit 6212d1c

Browse files
remove empty line at start of fun dec
1 parent 88b0cbc commit 6212d1c

File tree

5 files changed

+91
-22
lines changed

5 files changed

+91
-22
lines changed

NEWS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
auto-save edits in general (Code -> Saving -> Auto-Save), e.g. on idle editor
3636
or focus loss, so this feature becomes less relevant. (#631).
3737
- blank lines in function calls and headers are now removed, for the former only
38-
when there are no comments before or after the blank line (#629, #630, #635).
38+
when there are no comments before or after the blank line (#629, #630, #635,
39+
#723).
3940
- speed improvements: ~10% when cache is activated because transformers are not
4041
captured as character anymore (#679), ~3% in low-level optimization (#691).
4142
7% by requiring magrittr 2.0 (#681), ~8% by dropping unused transformers

R/rules-line-breaks.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ remove_line_break_before_round_closing_after_curly <- function(pd) {
173173

174174
remove_line_breaks_in_fun_dec <- function(pd) {
175175
if (is_function_dec(pd)) {
176-
round_after <- pd$token == "')'" & pd$token_before != "COMMENT"
176+
round_after <- (pd$token == "')'" | pd$token_before == "'('") & pd$token_before != "COMMENT"
177177
pd$lag_newlines[pd$lag_newlines > 1L] <- 1L
178178
pd$lag_newlines[round_after] <- 0L
179179
}

tests/testthat/fun_dec/line_break_fun_dec-in.R

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,16 @@ a <- function(x,
3333
y) {
3434
x - 1
3535
}
36+
37+
38+
a <- function(
39+
x,
40+
y) {
41+
x - 1
42+
}
43+
44+
a <- function( #
45+
x,
46+
y) {
47+
x - 1
48+
}

tests/testthat/fun_dec/line_break_fun_dec-in_tree

Lines changed: 63 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/fun_dec/line_break_fun_dec-out.R

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,15 @@ a <- function(x,
3232
y) {
3333
x - 1
3434
}
35+
36+
37+
a <- function(x,
38+
y) {
39+
x - 1
40+
}
41+
42+
a <- function( #
43+
x,
44+
y) {
45+
x - 1
46+
}

0 commit comments

Comments
 (0)