-
Notifications
You must be signed in to change notification settings - Fork 6
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
Remove {prettycode} dependency in favour of cli::code_highlight()
#488
base: main
Are you sure you want to change the base?
Conversation
Current Aviator status
This pull request is currently open (not queued). How to mergeTo merge this PR, comment
See the real-time status of this PR on the
Aviator webapp.
Use the Aviator Chrome Extension
to see the status of your PR within GitHub.
|
Thanks! I think we need the highlighting by default, most users don't read the doc or use options, they just use
If it's a hassle I can take those, it's important for me that we make it as a little of a breaking change as possible. |
Heya, thanks for the review! About whether to add highlighting by default, I'm happy to make this change if you think it's definitely the way to go. I was thinking that it's probably a fairly small minority of users who are using {prettycode} already, so while turning it on as a default would have the benefit of not removing colours for a small number of users, the potential downside would be that it could introduce an unwanted feature for the majority. That said, many people might also like it a lot. What do you think, best to turn it on for everyone and maybe advertise how to turn it off in About the As far as a global option to set
Do you mind pointing me to where this is please? I had a look but I couldn't find the bit you're referring to... |
Fair point. I thought most had prettycode installed, it is or was used by styler, but styler might not be as common as I expect. In any case I believe the code highlighting is a great feature and should be the default.
Yes
It's ok to skip it, I don't believe people used it other than maybe interactively, and it's not recorded in snapshots.
You are correct, no need to have a local option for this
I wasn't clear, I meant that we "would" mention, if we implemented this option So there's much less to change after all :D. |
Hey @moodymudskipper, I've made the suggested changes now. Things to note:
Thanks! |
This comment was marked as resolved.
This comment was marked as resolved.
We have a problem with cli :( x <- paste0("fun('", strrep("-", 1000), "')")
prettycode::highlight(x)
#> [1] "fun('----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------')"
cli::code_highlight(x)
#> [1] "fun([1000 chars quoted with '''])" Created on 2024-09-30 with reprex v2.1.0 I had pushed a fix to prettycode : r-lib/prettycode#21 that in fact hasn't been pushed to CRAN, and maybe won't ever be as it looks prettycode might as well retire (Gabor maintains both cli and prettycode) I opened this: r-lib/cli#726 Even if it doesn't change anything for CRAN versions I'd like cli to handle this on dev before I merge this |
Good catch! Hopefully will be fixed in cli soon. |
I proposed a PR there, it's better than what I had pushed to prettycode so hopefully this is all good news. r-lib/cli#727 Thanks for your patience! |
No rush on my end 🙂 |
As discussed in #486.
The only thing to note is that this changes the behaviour of the
constructive_pretty
global option. Previously this defaulted toTRUE
with an additional requirement that {prettycode} be installed, but now it defaults toFALSE
and the user has to manually override it. IMO it's nice to have the option to use highlighting, but there would be some hidden costs to turning it on by default:{cli}'s hyperlinks might be annoying if people accidentally click them when trying to copy code from the console
Highlighting will likely look quite different to the user's editor theme, so turning it on by default would naturally introduce some visual dissonance and potentially make {constructive} feel subtly worse to use
Some users only find a very small number of themes easy to read, e.g. due to colourblindness, so {cli}'s application of colour might not be an improvement for everyone
Thanks!