diff --git a/NEWS.md b/NEWS.md index bb4f73768..9bc104a73 100644 --- a/NEWS.md +++ b/NEWS.md @@ -30,6 +30,8 @@ cli progress bars. It makes cli redraw the progress bar for every progress update. +* Fix issues with `ansi_strwrap()` having `\r` in the string (#667) + # cli 3.6.6 * New `{.num}` and `{.bytes}` inline styles to format numbers diff --git a/R/ansiex.R b/R/ansiex.R index 9369db864..3a9ffd7c3 100644 --- a/R/ansiex.R +++ b/R/ansiex.R @@ -631,7 +631,7 @@ ansi_strwrap <- function( # First we need to remove the multiple spaces, to make it easier to # map the strings later on. We do this per paragraph, to keep paragraphs. - pars <- strsplit(x, "\n[ \t\n]*\n", perl = TRUE) + pars <- strsplit(x, "\r?\n[ \t\n\r]*\r?\n", perl = TRUE) pars <- lapply(pars, ansi_trimws) # Within paragraphs, replace multiple spaces with one, except when there @@ -640,11 +640,11 @@ ansi_strwrap <- function( # some is outside, but for now, we'll live with this limitation. pars <- lapply(pars, function(s) { # First replace multiple spaces that are not at the end of a sentence - s <- gsub("(?