tidyverse / reprex

Render bits of R code for sharing, e.g., on GitHub or StackOverflow.
https://reprex.tidyverse.org
Other
741 stars 80 forks source link

Prevent prex from changing certain session options #427

Closed jennybc closed 2 years ago

jennybc commented 2 years ago

Now, first, remember that prex() is unexported precisely because it creates leakage between your current R session and your (re)prex. So in general, prex() users have to take the bad with the good.

But we could try harder to leave certain things the way we found them.

Consider these options, which we inject into to-be-(re)prexed code:

https://github.com/tidyverse/reprex/blob/318363cf7a911010ebb1593765cc21ec207d2d10/R/reprex_document.R#L131-L141

prex() could note the original values of keep.source, rlang_backtrace_on_error_report, and crayon.enabled and make a point of scheduling their restoration.

jennybc commented 2 years ago

Before the fix

Screen Shot 2022-09-15 at 4 03 37 PM

After the fix

Screen Shot 2022-09-15 at 4 02 50 PM