Skip to content

Commit

Permalink
wrapi_text: assign length of pieces to variable
Browse files Browse the repository at this point in the history
This is already used in two spots, and the next commit will introduce
a third.

(While touching these lines, switch to more conventional spacing.)
  • Loading branch information
kyleam committed Jul 10, 2024
1 parent c59f59a commit da3cb85
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions R/util.R
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ wrapi_text <- function(
}

start <- NULL; shift <- 0
for(i in 2:length(pieces)){
npieces <- length(pieces)
for (i in 2:npieces) {
pieces_sep <- pieces[(1 + shift):i]
add <- paste0(pieces_sep, collapse = wrap_chr)
s <- cat_start(start = start, add = add, sep = wrap_chr)
Expand All @@ -191,7 +192,7 @@ wrapi_text <- function(
}else{
pieces_start <- pieces[(1 + shift):(i-1)]
add <- paste(paste0(pieces_start, collapse = wrap_chr), pieces[i], sep = newline_sep)
if(i == length(pieces)){
if (i == npieces) {
s <- cat_start(start = start, add = add, sep = "")
}else{
start <- cat_start(start = start, add = add, sep = "")
Expand Down

0 comments on commit da3cb85

Please sign in to comment.