@@ -192,8 +192,11 @@ needs_indention <- function(pd,
192
192
# '
193
193
# ' * there is no multi-line token between the trigger and the first line break.
194
194
# ' * there is no other token between the potential trigger and the first line
195
- # ' break that is going to cause indention.
196
- # '
195
+ # ' break that is going to cause indention. Note that such an other trigger
196
+ # ' only causes indention if there is a line break after that other token, not
197
+ # ' otherwise. See 'Details' for an example where there is such an other
198
+ # ' trigger, but since the next token is on the same line as the other trigger,
199
+ # ' no indention is caused by that other trigger.
197
200
# ' @param pd A parse table.
198
201
# ' @param potential_trigger_pos the index of the token in the parse table
199
202
# ' for which it should be checked whether it should trigger indention.
@@ -203,6 +206,8 @@ needs_indention <- function(pd,
203
206
# ' @return `TRUE` if indention is needed, `FALSE` otherwise.
204
207
# ' @importFrom rlang seq2
205
208
# ' @keywords internal
209
+ # ' @examples
210
+ # ' style_text("call(named = c, \nnamed = b)", strict = FALSE)
206
211
needs_indention_one <- function (pd ,
207
212
potential_trigger_pos ,
208
213
other_trigger_tokens ) {
@@ -219,9 +224,14 @@ needs_indention_one <- function(pd,
219
224
potential_trigger_pos
220
225
)
221
226
222
- other_trigger_on_same_line <-
223
- pd $ token [remaining_row_idx_between_trigger_and_line_break ] %in%
224
- other_trigger_tokens
227
+ other_trigger_on_same_line <- (
228
+ pd $ token [remaining_row_idx_between_trigger_and_line_break ] %in%
229
+ other_trigger_tokens
230
+ ) & (
231
+ pd $ lag_newlines [remaining_row_idx_between_trigger_and_line_break + 1L ] >
232
+ 0L
233
+ )
234
+
225
235
226
236
! any(multi_line_token ) & ! any(other_trigger_on_same_line )
227
237
}
0 commit comments