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: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
- `style_dir()` and `style_pkg()` now apply directory exclusion recursively with
`exclude_dirs` (#676).
- `switch()` now has line breaks after every argument to match the tidyverse
style guide (#722).
style guide (#722, #727).
- unary `+` before a function call does not give an error anymore, as before
version 1.3.0 (#697).
- cache is now correctly invalidated when style guide arguments change (#647).
Expand Down
4 changes: 2 additions & 2 deletions R/rules-line-breaks.R
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ set_line_break_after_opening_if_call_is_multi_line <- function(pd,
if (!is_function_call(pd) && !is_subset_expr(pd)) {
return(pd)
}
has_force_text_before <- pd$text[next_non_comment(pd, 0)] %in% force_text_before
has_force_text_before <- last(pd$child[[1]]$text) %in% force_text_before
if (has_force_text_before) {
break_pos <- c(
which(lag(pd$token %in% c("','", "COMMENT"))),
Expand All @@ -253,7 +253,7 @@ set_line_break_after_opening_if_call_is_multi_line <- function(pd,
}
exception_pos <- c(
which(pd$token %in% except_token_after),
ifelse(pd$child[[1]]$text[1] %in% except_text_before, break_pos, NA)
ifelse(last(pd$child[[1]]$text) %in% except_text_before, break_pos, NA)
)
pd$lag_newlines[setdiff(break_pos, exception_pos)] <- 1L
if (has_force_text_before) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,25 @@ if_else(a,
ifelse(x,
y, z
)


# namespacing
base::switch(f,
x = 2,
y = 3
)

base::switch(
f,
x = 2,
y = 3
)

dplyr::ifelse(x,
1, 32
)

dplyr::ifelse(
x,
1, 32
)

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

Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,24 @@ if_else(a,
ifelse(x,
y, z
)


# namespacing
base::switch(f,
x = 2,
y = 3
)

base::switch(f,
x = 2,
y = 3
)

dplyr::ifelse(x,
1, 32
)

dplyr::ifelse(
x,
1, 32
)