Skip to content

Commit c339fa8

Browse files
update documentation for needs_indention and drop unnecessary parameter token.
1 parent 65d99f7 commit c339fa8

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

R/modify_pd.R

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ indent_without_paren <- function(pd, indent_by = 2) {
6262
compute_indent_indices <- function(pd, token = "'('", indent_last = FALSE) {
6363
npd <- nrow(pd)
6464
opening <- which(pd$token %in% token)[1]
65-
if (!needs_indention(pd, token, opening)) return(numeric(0))
65+
if (!needs_indention(pd, opening)) return(numeric(0))
6666
start <- opening + 1
6767
stop <- npd - ifelse(indent_last, 0, 1)
6868
which(between(seq_len(npd), start, stop))
@@ -72,17 +72,15 @@ compute_indent_indices <- function(pd, token = "'('", indent_last = FALSE) {
7272
#' Check whether indention is needed
7373
#'
7474
#' @param pd A parse table.
75-
#' @param token Which token the check should be based on.
7675
#' @param opening the index of the opening parse table. Since always computed
7776
#' before this function is called, it is included as an argument so it does
7877
#' not have to be recomputed.
7978
#' @return returns `TRUE` if indention is needed, `FALSE` otherwise. Indention
80-
#' is needed:
81-
#' * if `token` occurs in `pd`.
82-
#' * if there is no child that starts on the same line as `token` and
83-
#' "opens" indention without closing it on this line.
79+
#' is needed if and only if:
80+
#' * the opening token is not `NA`.
81+
#' * if there is a multi-line token before the first line break.
8482
#' @return `TRUE` if indention is needed, `FALSE` otherwise.
85-
needs_indention <- function(pd, token = "'('", opening) {
83+
needs_indention <- function(pd, opening) {
8684
if (is.na(opening)) return(FALSE)
8785
before_first_break <- which(pd$lag_newlines > 0)[1] - 1
8886
if (is.na(before_first_break)) return(FALSE)

man/needs_indention.Rd

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

0 commit comments

Comments
 (0)