Skip to content
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
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ editor_options:

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

- There is now always one line break after `{` and before `#` (#916).

- the cache is also invalidated on changing the stylerignore markers (#932).

- `{` is not put on a new line after `=` and in `function() {` for some edge
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 @@ -144,7 +144,7 @@ set_line_break_around_comma_and_or <- function(pd, strict) {
style_line_break_around_curly <- function(strict, pd) {
if (is_curly_expr(pd) && nrow(pd) > 2) {
closing_before <- pd$token == "'}'"
opening_before <- (pd$token == "'{'") & (pd$token_after != "COMMENT")
opening_before <- (pd$token == "'{'")
to_break <- lag(opening_before, default = FALSE) | closing_before
len_to_break <- sum(to_break)
pd$lag_newlines[to_break] <- ifelse(rep(strict, len_to_break),
Expand Down
3 changes: 2 additions & 1 deletion tests/testthat/indention_multiple/overall-out.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ a <- function(x) {
22 + 1
))
if (x > 10) {
for (x in 22) { # FIXME in operator only to be surrounded by one space. What about %in%?
for (x in 22) {
# FIXME in operator only to be surrounded by one space. What about %in%?
prin(x)
}
}
Expand Down
10 changes: 10 additions & 0 deletions tests/testthat/line_breaks_and_other/curly-in.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,13 @@ test_that("I am here", {
a_test(x)
}
)

test_that(
desc = "bla",
code = {



# comment
expect_equal(1 + 1, 2)
})
8 changes: 8 additions & 0 deletions tests/testthat/line_breaks_and_other/curly-out.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,11 @@ if (1 > 3) {
test_that("I am here", {
a_test(x)
})

test_that(
desc = "bla",
code = {
# comment
expect_equal(1 + 1, 2)
}
)