cli icon indicating copy to clipboard operation
cli copied to clipboard

Inaccuracy in documentation of ansi_substr

Open robustessay opened this issue 5 months ago • 1 comments

The documentation for ansi_substr states "works exactly like the original" but this is not true because it can't be used as a replacement function like base::substr. It would be nice to have this implemented.

packageVersion('cli') [1] '3.6.5' x = '1234567890' base::substr(x,3,5) [1] "345" base::substr(x,3,5) = 'ABC' x [1] "12ABC67890" cli::ansi_substr(x,3,5) <cli_ansi_string> [1] ABC

But try as replacement:

cli::ansi_substr(x,3,5) = 'XYZ' Error: 'ansi_substr<-' is not an exported object from 'namespace:cli'

robustessay avatar Jun 23 '25 15:06 robustessay

ansi_substr<-() is a different function from ansi_substr().

gaborcsardi avatar Jun 23 '25 15:06 gaborcsardi