feat: Rework view() to better work with RStudio and Positron#1603
Merged
krlmlr merged 3 commits intotidyverse:mainfrom Sep 30, 2024
Merged
feat: Rework view() to better work with RStudio and Positron#1603krlmlr merged 3 commits intotidyverse:mainfrom
view() to better work with RStudio and Positron#1603krlmlr merged 3 commits intotidyverse:mainfrom
Conversation
view() to better work with RStudio and Positronview() to better work with RStudio and Positron
krlmlr
approved these changes
Sep 30, 2024
Member
krlmlr
left a comment
There was a problem hiding this comment.
Thanks, great!
NEWS bullets are added by CI/CD from the PR title once merged, don't worry about it.
Co-authored-by: Kirill Müller <krlmlr@users.noreply.github.com>
krlmlr
reviewed
Sep 30, 2024
Member
|
Thanks! Happy to release as needed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1551 (while I was here, I may as well...)
In RStudio and Positron, when
View(foo)is called, we check iffooexists as a symbol bound in the parent environment. If it does, we can "track" the lifetime of that object and auto update the data viewer when the user makes changes to it. This doesn't work withview()Screen.Recording.2024-09-30.at.10.56.25.AM.mov
This is because in
view()we were actually inlining the whole data frame object, rather than the expression the user typed in. So RStudio and Positron can't find anything to "track". This was also causing issues in Positron too actually (the inlined data frame could overwhelm us) posit-dev/positron#4702.@lionel- and I thought about this a bit and came up with an approach where we capture the user input to
view()and use that to reconstruct an equivalent call toView()that we call in the parent environment. This mimics the idea of the user callingView(foo)directly in the global environment, so that RStudio/Positron can "track"foocorrectly.xisn't a data frame, we don't do any of this. We "make"xinto a data frame ourselves, so RStudio and Positron won't have anything to "track" in these cases so we don't do anything specialxis a data frame but comes from something likeview(cbind(foo, foo)), we do the fancy thing to recall this asView()in the parent frame, which works fine, but of course RStudio and Positron still won't have anything to track because this is an ephemeral object. This is expected.It works like this now:
Screen.Recording.2024-09-30.at.10.54.40.AM.mov
Screen.Recording.2024-09-30.at.10.55.18.AM.mov
Side note, how do you add news bullets in tibble?