-
Notifications
You must be signed in to change notification settings - Fork 151
Open
Description
rlang::entrace() is removing line returns.
- a single line return (i.e.,
\n) is replaced with a space (i.e.,) - a two or more line returns (e.g.,
\n\n,\n\n\n\n) are reduces to just a double return (i.e.,\n\n)
packageVersion("rlang")
#> [1] '1.1.7'
get_message <- function(message, handler) {
tryCatch(
withCallingHandlers(
warning(message, call. = FALSE),
warning = handler
),
warning = conditionMessage
)
}
# single
get_message("zero\none\ntwo", force)
#> [1] "zero\none\ntwo"
get_message("zero\none\ntwo", rlang::entrace)
#> [1] "zero one two"
# double, multiple
get_message("zero\n\none\n\n\n\ntwo", force)
#> [1] "zero\n\none\n\n\n\ntwo"
get_message("zero\n\none\n\n\n\ntwo", rlang::entrace)
#> [1] "zero\n\none\n\ntwo"
withCallingHandlers(
warning("zero\none\ntwo", call. = FALSE),
warning = force
)
#> Warning: zero
#> one
#> two
withCallingHandlers(
warning("zero\none\ntwo", call. = FALSE),
warning = rlang::entrace
)
#> Warning: zero one twoCreated on 2026-02-01 with reprex v2.1.1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels