R/count_trailing_spaces.R

Defines functions count_trailing_spaces

#' Count the number of spaces before the first character
#' @param line line of text
#' @return the number of spaces before the first character
#' @author Richèl J.C. Bilderbeek
#' @noRd
count_trailing_spaces <- function(
  line
) {
  for (i in 1:nchar(line)) {
    char <- substring(line, i, i)
    if (char != " ") return(i - 1)
  }
  nchar(line)
}
ropensci/beautier documentation built on March 12, 2019, 8:27 p.m.