From cc05013833976d298779fc5341d9989c82ced85e Mon Sep 17 00:00:00 2001 From: Bill Denney Date: Fri, 3 Oct 2025 14:10:05 -0400 Subject: [PATCH 1/2] Fix ansi_strwrap() issue with \r in the string --- NEWS.md | 1 + R/ansiex.R | 11 ++++++----- tests/testthat/test-ansiex.R | 5 +++++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/NEWS.md b/NEWS.md index e1a1cf4f7..23ebb9e7e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,7 @@ * New `{.num}` and `{.bytes}` inline styles to format numbers and bytes (@m-muecke, #644, #588, #643). +* Fix issues with `ansi_strwrap()` having `\r` in the string (#667) # cli 3.6.5 diff --git a/R/ansiex.R b/R/ansiex.R index 7accebe81..5fe2674a0 100644 --- a/R/ansiex.R +++ b/R/ansiex.R @@ -589,7 +589,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 @@ -598,11 +598,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("(? Date: Thu, 24 Sep 2026 13:55:37 +0200 Subject: [PATCH 2/2] Correct NEWS entry location --- NEWS.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 3dec6a523..9bc104a73 100644 --- a/NEWS.md +++ b/NEWS.md @@ -30,11 +30,12 @@ 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 and bytes (@m-muecke, #644, #588, #643). -* Fix issues with `ansi_strwrap()` having `\r` in the string (#667) # cli 3.6.5