@@ -65,12 +65,12 @@ set_line_break_before_curly_opening <- function(pd) {
65
65
~ next_terminal(pd [.x , ], vars = " token_after" )$ token_after
66
66
) != " '{'"
67
67
last_expr_idx <- max(which(pd $ token == " expr" ))
68
- is_last_expr <- ifelse(pd $ token [ 1 ] %in% c(" IF" , " WHILE" ),
68
+ is_last_expr <- ifelse(any( c(" IF" , " WHILE" ) == pd $ token [ 1 ] ),
69
69
# rule not applicable for if and while
70
70
TRUE , (line_break_to_set_idx + 1L ) == last_expr_idx
71
71
)
72
72
73
- no_line_break_before_curly_idx <- pd $ token [line_break_to_set_idx ] %in% " EQ_SUB"
73
+ no_line_break_before_curly_idx <- any( pd $ token [line_break_to_set_idx ] == " EQ_SUB" )
74
74
linebreak_before_curly <- ifelse(is_function_call(pd ),
75
75
# if in function call and has pipe, it is not recognized as function call
76
76
# and goes to else case
@@ -85,7 +85,7 @@ set_line_break_before_curly_opening <- function(pd) {
85
85
no_line_break_before_curly_idx
86
86
)
87
87
is_not_curly_curly_idx <- line_break_to_set_idx [should_be_on_same_line ]
88
- pd $ lag_newlines [1 + is_not_curly_curly_idx ] <- 0L
88
+ pd $ lag_newlines [1L + is_not_curly_curly_idx ] <- 0L
89
89
90
90
91
91
# other cases: line breaks
@@ -99,10 +99,10 @@ set_line_break_before_curly_opening <- function(pd) {
99
99
]
100
100
if (is_function_dec(pd )) {
101
101
should_not_be_on_same_line_idx <- setdiff(
102
- 1 + should_not_be_on_same_line_idx , nrow(pd )
102
+ 1L + should_not_be_on_same_line_idx , nrow(pd )
103
103
)
104
104
} else {
105
- should_not_be_on_same_line_idx <- 1 + should_not_be_on_same_line_idx
105
+ should_not_be_on_same_line_idx <- 1L + should_not_be_on_same_line_idx
106
106
}
107
107
pd $ lag_newlines [should_not_be_on_same_line_idx ] <- 1L
108
108
@@ -150,7 +150,7 @@ set_line_break_around_comma_and_or <- function(pd, strict) {
150
150
}
151
151
152
152
style_line_break_around_curly <- function (strict , pd ) {
153
- if (is_curly_expr(pd ) && nrow(pd ) > 2 ) {
153
+ if (is_curly_expr(pd ) && nrow(pd ) > 2L ) {
154
154
closing_before <- pd $ token == " '}'"
155
155
opening_before <- (pd $ token == " '{'" )
156
156
to_break <- lag(opening_before , default = FALSE ) | closing_before
0 commit comments