Skip to content

Commit a860c5e

Browse files
Merge 0ce719a into cffab1e
2 parents cffab1e + 0ce719a commit a860c5e

File tree

5 files changed

+23
-2
lines changed

5 files changed

+23
-2
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ editor_options:
1919

2020
- If there are only empty lines in a code chunk, they are all removed (#936).
2121

22+
- There is now always one line break after `{` and before `#` (#916).
23+
2224
- the cache is also invalidated on changing the stylerignore markers (#932).
2325

2426
- `{` is not put on a new line after `=` and in `function() {` for some edge

R/rules-line-breaks.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ set_line_break_around_comma_and_or <- function(pd, strict) {
144144
style_line_break_around_curly <- function(strict, pd) {
145145
if (is_curly_expr(pd) && nrow(pd) > 2) {
146146
closing_before <- pd$token == "'}'"
147-
opening_before <- (pd$token == "'{'") & (pd$token_after != "COMMENT")
147+
opening_before <- (pd$token == "'{'")
148148
to_break <- lag(opening_before, default = FALSE) | closing_before
149149
len_to_break <- sum(to_break)
150150
pd$lag_newlines[to_break] <- ifelse(rep(strict, len_to_break),

tests/testthat/indention_multiple/overall-out.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ a <- function(x) {
88
22 + 1
99
))
1010
if (x > 10) {
11-
for (x in 22) { # FIXME in operator only to be surrounded by one space. What about %in%?
11+
for (x in 22) {
12+
# FIXME in operator only to be surrounded by one space. What about %in%?
1213
prin(x)
1314
}
1415
}

tests/testthat/line_breaks_and_other/curly-in.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,13 @@ test_that("I am here", {
3131
a_test(x)
3232
}
3333
)
34+
35+
test_that(
36+
desc = "bla",
37+
code = {
38+
39+
40+
41+
# comment
42+
expect_equal(1 + 1, 2)
43+
})

tests/testthat/line_breaks_and_other/curly-out.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,11 @@ if (1 > 3) {
3030
test_that("I am here", {
3131
a_test(x)
3232
})
33+
34+
test_that(
35+
desc = "bla",
36+
code = {
37+
# comment
38+
expect_equal(1 + 1, 2)
39+
}
40+
)

0 commit comments

Comments
 (0)