Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent result width for ansi_collapse(style = "head") #570

Open
salim-b opened this issue Jan 27, 2023 · 0 comments
Open

Inconsistent result width for ansi_collapse(style = "head") #570

salim-b opened this issue Jan 27, 2023 · 0 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@salim-b
Copy link
Contributor

salim-b commented Jan 27, 2023

The documentation of ansi_collapse() states about param width:

Limit for the display width of the result, in characters. This is a hard limit, and the output will never exceed it.

But the following results prove this wrong:

library(magrittr)
x <- c("loooooooong", "healthy live the Penguin")

cli::ansi_collapse(x) %T>% print() %>% nchar()
#> [1] "loooooooong, and healthy live the Penguin"
#> [1] 41
cli::ansi_collapse(x, width = 1, style = "head") %T>% print() %>% nchar()
#> [1] "…"
#> [1] 1
cli::ansi_collapse(x, width = 2, style = "head") %T>% print() %>% nchar()
#> [1] "lo…"
#> [1] 3
cli::ansi_collapse(x, width = 3, style = "head") %T>% print() %>% nchar()
#> [1] "loo…"
#> [1] 4
cli::ansi_collapse(x, width = 4, style = "head") %T>% print() %>% nchar()
#> [1] "…, …"
#> [1] 4
cli::ansi_collapse(x, width = 5, style = "head") %T>% print() %>% nchar()
#> [1] "l…, …"
#> [1] 5

Created on 2023-01-28 with reprex v2.0.2

(It's not really an issue for me, I just stumbled upon this while implementing #569 and thought it should be reported. 🙂)

@gaborcsardi gaborcsardi added the bug an unexpected problem or unintended behavior label Jan 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants