Skip to content

Commit 8b9a4a0

Browse files
committed
double -> single
1 parent 5e5eb3a commit 8b9a4a0

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

R/rules-indention.R

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ indent_braces <- function(pd, indent_by) {
1515
#'
1616
#' Necessary for consistent indention of the function declaration header.
1717
#' @param pd A parse table.
18-
#' @inheritParams is_double_indent_function_declaration
18+
#' @inheritParams is_single_indent_function_declaration
1919
#' @seealso set_unindention_child update_indention_ref_fun_dec
2020
#' @keywords internal
2121
unindent_fun_dec <- function(pd, indent_by = 2L) {
2222
if (is_function_declaration(pd)) {
2323
idx_closing_brace <- which(pd$token == "')'")
2424
fun_dec_head <- seq2(2L, idx_closing_brace)
25-
if (is_double_indent_function_declaration(pd, indent_by = indent_by)) {
25+
if (is_single_indent_function_declaration(pd, indent_by = indent_by)) {
2626
pd$indent[fun_dec_head] <- indent_by
2727
pd$indent[idx_closing_brace] <- 0L
2828
} else {
@@ -32,20 +32,21 @@ unindent_fun_dec <- function(pd, indent_by = 2L) {
3232
pd
3333
}
3434

35-
#' Is the function declaration double indented?
35+
#' Is the function declaration single indented?
3636
#'
3737
#' Assumes you already checked if it's a function with
38-
#' `is_function_declaration`. It is double indented if the first token
38+
#' `is_function_declaration`. It is single indented if the first token
3939
#' after the first line break that is a `"SYMBOL_FORMALS"`.
4040
#' @param pd A parse table.
4141
#' @inheritParams tidyverse_style
4242
#' @keywords internal
43-
is_double_indent_function_declaration <- function(pd, indent_by = 2L) {
43+
is_single_indent_function_declaration <- function(pd, indent_by = 2L) {
4444
head_pd <- vec_slice(pd, -nrow(pd))
4545
line_break_in_header <- which(head_pd$lag_newlines > 0L & head_pd$token == "SYMBOL_FORMALS")
4646
if (length(line_break_in_header) > 0L) {
4747
# indent results from applying the rules, spaces is the initial spaces
4848
# (which is indention if a newline is ahead)
49+
# The 2L factor is kept to convert double indent to single indent
4950
pd$spaces[line_break_in_header[1L] - 1L] <= 2L * indent_by
5051
} else {
5152
FALSE
@@ -133,7 +134,7 @@ NULL
133134
#'
134135
#' @keywords internal
135136
update_indention_ref_fun_dec <- function(pd_nested) {
136-
if (is_function_declaration(pd_nested) && !is_double_indent_function_declaration(pd_nested)) {
137+
if (is_function_declaration(pd_nested) && !is_single_indent_function_declaration(pd_nested)) {
137138
seq <- seq2(3L, nrow(pd_nested) - 2L)
138139
pd_nested$indention_ref_pos_id[seq] <- pd_nested$pos_id[2L]
139140
}

R/rules-line-breaks.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ remove_line_break_before_round_closing_after_curly <- function(pd) {
236236

237237
remove_line_breaks_in_fun_dec <- function(pd) {
238238
if (is_function_declaration(pd)) {
239-
is_double_indention <- is_double_indent_function_declaration(pd)
239+
is_double_indention <- is_single_indent_function_declaration(pd)
240240
round_after <- (
241241
pd$token == "')'" | pd$token_before == "'('"
242242
) &

man/is_double_indent_function_declaration.Rd renamed to man/is_single_indent_function_declaration.Rd

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)