Skip to content

Commit 3372f00

Browse files
checking for double indention must be before changing the nest's newlines, as the result depends on nest's newlines.
1 parent 8208348 commit 3372f00

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

R/rules-line-breaks.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,14 @@ remove_line_break_before_round_closing_after_curly <- function(pd) {
231231

232232
remove_line_breaks_in_fun_dec <- function(pd) {
233233
if (is_function_declaration(pd)) {
234+
is_double_indention <- is_double_indent_function_declaration(pd)
234235
round_after <- (
235236
pd$token == "')'" | pd$token_before == "'('"
236237
) &
237238
pd$token_before != "COMMENT"
238239
pd$lag_newlines[pd$lag_newlines > 1L] <- 1L
239240
pd$lag_newlines[round_after] <- 0L
240-
if (is_double_indent_function_declaration(pd)) {
241+
if (is_double_indention) {
241242
pd$lag_newlines[lag(pd$token == "'('")] <- 1L
242243
}
243244
}

tests/testthat/unindention/mixed-double-out.R

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ function(
5858
}
5959

6060

61-
function(x, y) {
61+
function(
62+
x, y) {
6263
1
6364
}
6465

@@ -70,9 +71,15 @@ function(x,
7071

7172

7273
# last brace
73-
function(x, y) NULL
74+
function(
75+
x, y) {
76+
NULL
77+
}
7478

75-
function(x, y) NULL
79+
function(
80+
x, y) {
81+
NULL
82+
}
7683

7784
function(
7885
x,

0 commit comments

Comments
 (0)