@@ -298,7 +298,9 @@ indentation_linter <- function(indent = 2L, hanging_indent_style = c("tidy", "al
298298}
299299
300300find_new_indent <- function (current_indent , change_type , indent , hanging_indent ) {
301- if (change_type == " hanging" ) {
301+ if (change_type == " suppress" ) {
302+ current_indent
303+ } else if (change_type == " hanging" ) {
302304 hanging_indent
303305 } else if (change_type == " double" ) {
304306 current_indent + 2L * indent
@@ -311,6 +313,7 @@ build_indentation_style_tidy <- function() {
311313 paren_tokens_left <- c(" OP-LEFT-BRACE" , " OP-LEFT-PAREN" , " OP-LEFT-BRACKET" , " LBB" )
312314 paren_tokens_right <- c(" OP-RIGHT-BRACE" , " OP-RIGHT-PAREN" , " OP-RIGHT-BRACKET" , " OP-RIGHT-BRACKET" )
313315 xp_last_on_line <- " @line1 != following-sibling::*[not(self::COMMENT)][1]/@line1"
316+ xp_inner_expr <- " preceding-sibling::*[1][self::expr and expr[SYMBOL_FUNCTION_CALL]]/*[not(self::COMMENT)]"
314317
315318 # double indent is tidyverse style for function definitions
316319 # triggered only if the closing parenthesis of the function definition is not on its own line and the opening
@@ -333,6 +336,18 @@ build_indentation_style_tidy <- function() {
333336 parent::expr[FUNCTION and not(@line1 = SYMBOL_FORMALS/@line1)]
334337 /OP-RIGHT-PAREN[@line1 = preceding-sibling::*[not(self::COMMENT)][1]/@line2]
335338 "
339+
340+ xp_suppress <- paste(
341+ glue :: glue("
342+ self::{paren_tokens_left}[
343+ @line1 = following-sibling::{paren_tokens_right}/{xp_inner_expr}[position() = 1]/@line1
344+ ]/following-sibling::{paren_tokens_right}[
345+ @line1 > {xp_inner_expr}[position() = last() - 1]/@line2
346+ ]"
347+ ),
348+ collapse = " | "
349+ )
350+
336351 xp_is_not_hanging <- paste(
337352 c(
338353 glue :: glue(
@@ -346,6 +361,8 @@ build_indentation_style_tidy <- function() {
346361 function (change ) {
347362 if (length(xml2 :: xml_find_first(change , xp_is_double_indent )) > 0L ) {
348363 " double"
364+ } else if (length(xml2 :: xml_find_first(change , xp_suppress )) > 0L ) {
365+ " suppress"
349366 } else if (length(xml2 :: xml_find_first(change , xp_is_not_hanging )) == 0L ) {
350367 " hanging"
351368 } else {
0 commit comments