-
Notifications
You must be signed in to change notification settings - Fork 65
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
Improve the print method #296
Conversation
Inspired by stringr::str_view() Fixes #290
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like a pretty big change in the print method to me! So much so that it gives me pause.
I've always assumed that the main benefit of having the "glue" class was to get the quote-free, clutter-free printing and this walks away from that. I know we have some regrets about the "glue" class, but this seems to undermine its main rationale?
This almost feels more like a str()
method. What do you think of me turning it into that?
(And, if so, yes I still think we need to do something when printing a glue object of length 0.)
I ran revdep checks and, as expected, only a saw a couple of failures due to this, including r-lib/testthat#1868. But in the course of figuring out that puzzle, I checked pillar locally and saw massive snapshot test change, which I think could be pretty widespread. I know that won't make tests fail on CRAN, in general, but it increases my hunch that we should introduce this display as a |
We should maybe talk this through live as it's definitely not a glue::glue("{x}", x = c("a", "b", "c\nd"))
#> a
#> b
#> c
#> d Created on 2023-09-25 with reprex v2.0.2 |
I've resolved the remaining discussion items; @jennybc we should chat to confirm that this makes sense. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still not sure I'm on board with this, but we'll discuss in person. I'm comfortable with how it's done.
|
||
truncated <- length(x) > max | ||
if (truncated) { | ||
x <- x[seq_len(max)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want this to affect the return value? I.e. print()
no longer passes x
through invisibly.
See discussion in #290 |
Inspired by stringr::str_view()
Fixes #290