Skip to content

Commit

Permalink
never remove line breaks when it moves code behind a comment
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzwalthert committed Dec 27, 2022
1 parent 0b34e99 commit f808f1c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/rules-line-breaks.R
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ set_line_break_around_curly_curly <- function(pd) {
closing_before <- (pd$token == "'}'") &
(pd$token_after == "'}'" | pd$token_before == "'}'")
if (any(opening_before) && any(closing_before)) {
pd$lag_newlines[lag(opening_before, default = FALSE)] <- 0L
pd$lag_newlines[closing_before] <- 0L
pd$lag_newlines[lag(opening_before, default = FALSE) & pd$token != "COMMENT"] <- 0L
pd$lag_newlines[closing_before & pd$token_before != "COMMENT"] <- 0L
}
}
pd
Expand Down
14 changes: 14 additions & 0 deletions tests/testthat/curly-curly/mixed-in.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,17 @@ call(
{{ x }},
{{ y}} := 3, f(bk)
)

call({{
#
1
}})

call({{
#
}})


{{
#
}}
13 changes: 13 additions & 0 deletions tests/testthat/curly-curly/mixed-out.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,16 @@ call(
{{ x }},
{{ y }} := 3, f(bk)
)

call({{
#
1 }})

call({{
#
}})


{{
#
}}

0 comments on commit f808f1c

Please sign in to comment.