Skip to content

Commit

Permalink
simplify verbose wrapping (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbarbone committed Dec 22, 2023
1 parent 7296922 commit 36aab5b
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions R/verbose.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,21 @@ verbose_message <- function(
stop(cond_verbose_label())
}

msg <-
if (isTRUE(.fill)) {
con <- file()
on.exit(close(con))
cat(..., file = con)
paste0(.label, readLines(con, warn = FALSE), collapse = "\n")
} else {
.makeMessage(.label, ...)
}
msg <- if (isTRUE(.fill)) {
collapse(
strwrap(
strsplit(collapse(..., sep = " "), "\n", fixed = TRUE)[[1]],
getOption("width") - nchar(.label),
prefix = .label
),
sep = "\n"
)
} else {
.makeMessage(.label, ...)
}

struct(
list(msg, call),
list(paste0(msg, "\n"), call),
names = c("message", "call"),
class = c("verboseMessage", "message", "condition")
)
Expand Down

0 comments on commit 36aab5b

Please sign in to comment.