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 @@ -47,6 +47,8 @@
* Preserve trailing blank line in roxygen examples to simplify concatenation of
examples (#880).
* added guarantee that styled code is parsable (#892).
* `indenty_by` is now also respected when curly braces are added to an if
statement by {styler} (#915).
* An error is now thrown on styling if input unicode characters can't be
correctly parsed for Windows and R < 4.2 (#883).
* styling of text does not error anymore when the R option `OutDec` is set to
Expand Down
7 changes: 6 additions & 1 deletion R/style-guides.R
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,12 @@ tidyverse_style <- function(scope = "tokens",
resolve_semicolon = resolve_semicolon,
add_brackets_in_pipe = add_brackets_in_pipe,
wrap_if_else_while_for_fun_multi_line_in_curly =
if (strict) wrap_if_else_while_for_fun_multi_line_in_curly
if (strict) {
purrr::partial(
wrap_if_else_while_for_fun_multi_line_in_curly,
indent_by = indent_by
)
}
)
}

Expand Down
10 changes: 10 additions & 0 deletions tests/testthat/indention_curly_brackets/custom-in.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

value <- 5
if (value > 0)
print(value)



if (value > 0) {
print(value)
}
45 changes: 45 additions & 0 deletions tests/testthat/indention_curly_brackets/custom-in_tree

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

11 changes: 11 additions & 0 deletions tests/testthat/indention_curly_brackets/custom-out.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

value <- 5
if (value > 0) {
print(value)
}



if (value > 0) {
print(value)
}
7 changes: 7 additions & 0 deletions tests/testthat/test-indention_curly.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ test_that("indention with multi-line curley and round is correct", {
), NA)
})

test_that("custom indention for curly braces is corretct ", {
expect_warning(test_collection("indention_curly_brackets",
"custom",
transformer = style_text, indent_by = 4
), NA)
})



test_that(paste(
Expand Down